Forrest logo
back to the go tool

go-env:tldr:27177

go-env: Show all environment variables.
$ go env
try on your machine

The go env command is used in the Go programming language to display the environment variables related to your Go installation. Environment variables are system-specific settings that customize the behavior of programs running on the system.

When you run go env, it prints a list of environment variables related to Go, such as the Go binary path, Go root directory, Go module settings, and more. These variables are useful to understand and configure your Go development environment.

Here are some common environment variables displayed by go env:

  • GOARCH: The architecture of the target platform, such as "amd64" or "arm".
  • GOOS: The operating system of the target platform, such as "windows" or "linux".
  • GOROOT: The root directory of the Go installation.
  • GOPATH: The workspace directory for Go projects.
  • GOBIN: The directory where Go binaries are installed.
  • GOMOD: The path to the current module definition file.
  • GOPRIVATE: A comma-separated list of module patterns indicating private repositories.
  • GO111MODULE: A flag to enable or disable Go modules. It can have values like "on", "off", or "auto".

By using the go env command, you can inspect and understand these variables to configure your Go development environment effectively.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the go tool