General

VariableDescription
GOROOTRoot directory of the Go installation (where the Go toolchain lives). Usually auto-detected.
GOPATHWorkspace directory for Go code. Default: ~/go. Contains src/, pkg/, and bin/ subdirectories. Used for storing downloaded modules and installed binaries.
GOBINDirectory where go install places compiled binaries. Default: $GOPATH/bin.
GOENVPath to the Go environment config file. Default: ~/.config/go/env.
GOTOOLDIRDirectory where Go build tools (asm, compile, link, etc.) are installed.

Modules

VariableDescription
GO111MODULEControls module mode. on = always use modules, off = never (use GOPATH mode), auto = use modules if go.mod exists (default since Go 1.16: on).
GOMODCACHEDirectory where downloaded modules are cached. Default: $GOPATH/pkg/mod.
GOPROXYComma-separated list of module proxy URLs. Default: https://proxy.golang.org,direct. direct means fall back to fetching directly from VCS. off disallows all downloads.
GONOPROXYComma-separated glob patterns of modules that should NOT go through the proxy (fetched directly from VCS).
GONOSUMDBComma-separated glob patterns of modules that should NOT be verified against the checksum database.
GONOSUMCHECKComma-separated glob patterns of modules that should NOT have their checksums validated (skips even local go.sum verification).
GOPRIVATEShorthand that sets both GONOPROXY and GONOSUMDB. Used for private/internal modules. Example: GOPRIVATE=github.com/mycompany/*.
GOSUMDBName and URL of the checksum database. Default: sum.golang.org. Set to off to disable checksum verification.
GOFLAGSDefault flags applied to every go command. Example: GOFLAGS=-mod=vendor.
GOWORKPath to a go.work file for multi-module workspaces. Set to off to disable workspace mode.

Build & Compilation

VariableDescription
GOOSTarget operating system for compilation. Examples: linux, darwin, windows, freebsd.
GOARCHTarget architecture. Examples: amd64, arm64, 386, arm, wasm.
CGO_ENABLED1 = enable cgo (allows calling C code), 0 = disable cgo. Default: 1 when compiling natively, 0 when cross-compiling.
CCC compiler to use for cgo. Default: cc or gcc.
CXXC++ compiler to use for cgo. Default: c++ or g++.
CGO_CFLAGSFlags passed to the C compiler during cgo compilation.
CGO_CPPFLAGSFlags passed to the C preprocessor during cgo compilation.
CGO_CXXFLAGSFlags passed to the C++ compiler during cgo compilation.
CGO_LDFLAGSFlags passed to the linker during cgo compilation.
CGO_FFLAGSFlags passed to the Fortran compiler during cgo compilation.
ARArchiver tool used for building C archives. Default: ar.
GOAMD64Microarchitecture level for GOARCH=amd64. Values: v1 (default, baseline), v2, v3, v4 (AVX-512).
GOARMARM floating-point architecture for GOARCH=arm. Values: 5, 6, 7 (default).
GOARM64ARM64 architecture features for GOARCH=arm64. Example: v8.0 (default).
GOMIPSFloating-point mode for MIPS. Values: hardfloat (default), softfloat.
GOPPC64Power PC architecture level. Values: power8 (default), power9, power10.
GOWASMComma-separated list of WebAssembly features for GOARCH=wasm.
GOTOOLCHAINControls which Go toolchain version to use. Values: local, auto, or a specific version like go1.21.0.

Linking

VariableDescription
GOLDFLAGSFlags passed to the Go linker.
GOEXPERIMENTComma-separated list of experimental Go features to enable/disable.

Testing & Debugging

VariableDescription
GORACEOptions for the race detector. Example: GORACE="log_path=/tmp/race halt_on_error=1".
GOMAXPROCSMaximum number of OS threads that can execute Go code simultaneously. Default: number of CPU cores.
GOTRACEBACKControls the detail level of stack traces on panic. Values: none, single (default), all, system, crash.
GODEBUGComma-separated list of debug settings. Examples: gctrace=1, schedtrace=1000, http2debug=1.

Caching & Temp

VariableDescription
GOCACHEDirectory for build cache. Default: ~/.cache/go-build (Linux/Mac). Set to off to disable.
GOTMPDIRDirectory for temporary files created during compilation. Default: system temp dir.

Version Control & Fetching

VariableDescription
GOVCSControls which VCS tools are allowed for fetching modules. Example: GOVCS=github.com:git,*:off (only allow git for GitHub, block all others). Default: `public:git
GOINSECUREComma-separated glob patterns of modules that can be fetched over insecure (HTTP) connections.
GOAUTHAuthentication credentials for fetching modules from private repos.

Quick Reference — Most Commonly Used

VariableTypical Use Case
GOOS / GOARCHCross-compilation (GOOS=linux GOARCH=amd64 go build)
GOPRIVATEPrivate repos (GOPRIVATE=github.com/mycompany/*)
GOPROXYCorporate proxy or air-gapped environments
CGO_ENABLEDDisable C dependencies for static binaries (CGO_ENABLED=0)
GOMAXPROCSTune concurrency at runtime
GODEBUGRuntime diagnostics (GODEBUG=gctrace=1)
GOFLAGSSet persistent build flags (GOFLAGS=-mod=vendor)
GOTOOLCHAINPin or auto-upgrade Go version per project

You can always check your current values with go env and set them persistently with go env -w VARIABLE=value.