Creating the Directory Structure
Explore different directory structures for Go command-line programs including flat, minimal, and comprehensive layouts. Understand how to organize commands, packages, and tests for clean, maintainable code in multi-developer projects.
Common directory structures for Go programs
We identified common elements of a Go program, but, how do we go about organizing them in a directory structure? We will discuss several common approaches.
Flat single directory
The flat single directory approach has no internal structure. All the files live in the project’s root directory. This is the approach used by multi-git 0.1, and it is appropriate for very small programs.
The minimal approach
The minimal approach advocates just two top-level directories: cmd ...