Importing
Context
Section titled “Context”Use import to bring other packages into scope. You can import single packages, multiple packages in a block, rename imports with aliases, or use a blank import (_) for side effects (e.g., registering a driver).
Example
Section titled “Example”Show different import styles.
Code example
Section titled “Code example”package main
import ( "fmt" "math/rand" myfmt "mylib/fmt" // alias _ "image/png" // blank import for side effect)
func main() { fmt.Println(rand.Intn(100)) myfmt.Println("Hello")}Output (example)
Section titled “Output (example)”42Hello