Search⌘ K

Packages and Imports

Explore how Go programs are structured using packages and imports. Understand the role of the main package and function, and learn how to import standard libraries and external packages for effective Go programming.

We'll cover the following...

Packages

Every Go program is made up of packages. Programs start running in package main.

Go (1.6.2)
package main
import "fmt"
func main() {
fmt.Printf("Hello, World!\n")
}

If you are writing an executable code (versus a library), then you need to define a main package and a main() function which will be the entry point to your ...