Posts

Showing posts from November, 2017

[Golang] The project directory structure

Image
This is a basic layout for Go application projects. It represents the most common directory structure with a number of small enhancements along with several supporting directories common to any real world application. Go Directories /cmd Main applications for this project.  The directory name for each application should match the name of the executable you want to have (e.g., /cmd/myapp).  Don't put a lot of code in the application directory unless you think that code can be imported and used in other projects. If this is the case then the code should live in the /pkg directory.  It's common to have a small main function that imports and invokes the code from the /internal and /pkgdirectories. /internal Private application and library code.  Put your actual application code in the /internal/app directory (e.g., /internal/app/myapp) and the code shared by those apps in the /internal/pkg directory (e.g., /internal/pkg/myprivlib). /pkg Library code that&