-
GOROOT:
This is the location where Go is installed on your system. Typically, it doesn't need to be set unless you want to switch between different Go versions. If Go is installed in the default location or via a package manager, GOROOT is automatically set by the Go installation.
-
GOPATH:
Before Go modules came into existence, GOPATH was essential. It specifies the root directory for your workspace where Go code, packages, and binaries are stored. With Go 1.11 and above, module support provides dependency management and module storage, reducing the reliance on GOPATH. However, some older projects and tools might still require GOPATH.
-
GOBIN:
This specifies the directory where go install will place compiled executables. By default, it's $GOPATH/bin. If not set, executables go to $GOPATH/bin or $GOROOT/bin, depending on whether GOPATH is set.
-
GO111MODULE:
This controls the module support, which can be set to on, off, or auto. Setting this to on forces Go to use modules even if the project is in your GOPATH. With auto, Go decides whether to use modules based on the presence of the go.mod file.
-
GOMOD:
Shows the path of the go.mod file for the current module except when modules are off. It is read-only.
-
GOCACHE:
Points to the cache directory that stores the build and test results. The default location depends on your operating system.
-
GOFLAGS:
This variable can be used to set default flags to go command-line operations.
-
GOMODCACHE:
Specifies the location for storing downloaded module files. By default, it's located at $GOPATH/pkg/mod.
-
GOENV:
Specifies the location of the file where Go environment variables are stored. It’s a read-only variable.
-
GOPROXY:
It determines the proxy or mirrors to use for downloading modules. Can be set to direct access or through a proxy URL.
-
GOSUMDB:
Indicates the name of the checksum database used for verifying module content. The default is sum.golang.org.
-
GONOPROXY and GONOSUMDB:
Specify patterns for module paths to bypass the proxy or checksum database.
-
GOINSECURE:
Specifies module patterns that can be fetched without HTTPS or without a valid certificate.