import declaration

The line near the top of a Go file that names the packages the file uses, such as import "fmt".

In more detail

Several imports can be grouped in parentheses. Importing a package you never use is a compile error, not a warning, which keeps files honest. The name you call the package by is the last part of its import path.

Example

import (
	"fmt"
	"os"
)

Related terms

Taught in

References