A Go package is a compilable unit of related source files. Import a package by name and reference its available identifiers with that name as a prefix, such as fmt.Println. section 1.2.4
Use packages through the Go toolchain:
- Group imports in parentheses and keep them alphabetized; go fmt can maintain this formatting. section 1.2.4
- Import standard-library packages such as fmt and net/http alongside external packages identified by module or URL paths. section 1.2.4
- Use go mod for dependency management and go get ./... to obtain package dependencies. section 1.2.4
Listing 1.9 Single package import
package main
import "fmt" #1
func main() {
fmt.Println("Hello World!") #2
}
A minimal main package imports fmt and calls fmt.Println, showing package-qualified use in a runnable program. section 1.2.4






