Andrew's Digital Garden

Packages in Go

Packages are a level above functions in Go. The main package represents an executable, and any other package is known as a library package, which can not have a main function. These library packages help split up code into more manageable pieces.

Packages can span multiple files, and the file names do not matter.

Declare the package with package <name>. Import with import <optional alias> <package name>

If a package requires initialisation, the init function can be used.

Private vs public functions: [[20200720101212-go-private]]

[[go]]

Packages in Go