March 2020
Intermediate to advanced
406 pages
8h 39m
English
When we discuss the layout of a Go program, we have a couple of different processes that we should follow. A common convention is to keep your main programs in a folder named cmd. Your other packages that you build to be executed from the main function should live in a pkg directory. This separation helps to encourage the reuse of packages. In the following example, if we want to reuse the notification package for both the CLI and web main programs, we have the ability to do that easily with one import. The following a screenshot shows this separation:

An anti-pattern for Go is to have a one-to-one file for package mapping. ...
Read now
Unlock full access