This section will provide some handy advice that will help you to develop better Go packages. We have covered that Go packages are organized in directories and can contain public and private elements. Public elements can be used both internally and externally from other packages, whereas private elements can only be used internally in a package.
Here are several good rules to follow to create superior Go packages:
- The first unofficial rule of a successful package is that its elements must be related in some way. Thus, you can create a package for supporting cars, but it would not be a good idea to create a single package for supporting both cars and bicycles. Put simply, it is better to split the functionality of a package unnecessarily into multiple packages than to add too much functionality to a single Go package. Additionally, packages should be made...