go env
The go subcommand that prints the settings the toolchain is using, such as GOPATH, GOOS and GOARCH.
In more detail
go env shows each Go environment variable and its current value, whether you set it or it is a default. It is the first thing to check when a build behaves differently on two machines. go env -w can save a setting for your user.
Example
go env GOPATH GOOS GOARCHRelated terms
- GOPATH — The Go setting that names a folder, by default go in your home folder, where downloaded modules are cached and installed tools are placed.
- GOOS and GOARCH — The two Go settings that choose the target operating system and processor family a build produces a binary for.
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
Taught in
- Installing the Go Toolchain — Concurrent Systems Programming with Go