package main
The special package name that makes a Go program executable, together with a function called main where the program starts.
In more detail
Any other package name produces a library that something else must import. When main returns, the whole program exits, even if goroutines are still running. go build on a main package produces a binary.
Example
package main
func main() {}Related terms
- Go package — A folder of Go source files that are compiled together and share one package name, which other code imports as a unit.
- go build — The go subcommand that compiles a package and its dependencies into an executable file and prints nothing when it succeeds.
- goroutine — A function running concurrently with the rest of a Go program, started by putting the go keyword before a call.
Taught in
- What Go Is and Why It Matters — Concurrent Systems Programming with Go
- Installing the Go Toolchain — Concurrent Systems Programming with Go
- Go Workspaces and Modules — Concurrent Systems Programming with Go
- Your First Program and go run — Concurrent Systems Programming with Go
- Variables, Typing, and Zero Values — Concurrent Systems Programming with Go
- Pointers and Memory — Concurrent Systems Programming with Go
- Arrays, Slices, and Maps — Concurrent Systems Programming with Go
- Structs and Methods — Concurrent Systems Programming with Go