6
Go Packages and Functions
The focus of this chapter is on Go packages, which are the Go way of organizing, delivering, and using code. Packages are used to organize related functionality in your code. As the package author, you design the package, including the public API consisting of exported constants, variables, types, and functions. Go also supports modules, which contain one or more packages. Modules are versioned following SemVer, allowing the module author to release updates and even breaking changes using a major.minor.patch
versioning scheme. This chapter will also explain the operation of defer
, which is typically used for cleaning up and releasing resources.
Regarding the visibility of package elements, Go follows a simple rule ...
Get Mastering Go - Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.