Package in Go.
Go treats files in a single directory as belonging to one package as long as they all have the same name in their package declarations.
Go code is organized into packages (similar to libraries or modules).
Package names are always in lower case.
The first statement in a Go source file must be
Go's convention is that the package name is the last element of the import path. See below.
Executable commands must always use package main.
Import Path (Package Id)
An import path is a string that uniquely identifies a package.
A package's import path corresponds to its location:
- inside a workspace
- or in a remote repository
The packages from the standard library are given short import paths such as “fmt” and “net/http”.
import ( "fmt" "base-path/package-name/go-source-file" )
The import statement tell the compiler what packages are needed by the source file.
The base path is the root path of (custom|user) package (not standard library or other external libraries)
By convention, each package is described in a comment immediately preceding its package declaration.
go get base_path/package-name