Documentation ¶
Overview ¶
Package cfg holds configuration shared by multiple parts of the go command.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Goos = envOr("GOOS", build.Default.GOOS) Goarch = envOr("GOARCH", build.Default.GOARCH) ExeSuffix = exeSuffix() // ModulesEnabled specifies whether the go command is running // in module-aware mode (as opposed to GOPATH mode). // It is equal to modload.Enabled, but not all packages can import modload. ModulesEnabled bool )
Global build parameters (used during package load)
var ( BuildA bool // -a flag BuildBuildmode string // -buildmode flag BuildBuildvcs = "auto" // -buildvcs flag: "true", "false", or "auto" BuildContext = defaultContext() BuildMod string // -mod flag BuildModExplicit bool // whether -mod was set explicitly BuildModReason string // reason -mod was set, if set by default BuildI bool // -i flag BuildMSan bool // -msan flag BuildASan bool // -asan flag BuildN bool // -n flag BuildO string // -o flag BuildP = runtime.GOMAXPROCS(0) // -p flag BuildPkgdir string // -pkgdir flag BuildRace bool // -race flag BuildToolexec []string // -toolexec flag BuildToolchainName string BuildToolchainCompiler func() string BuildToolchainLinker func() string BuildTrimpath bool // -trimpath flag BuildV bool // -v flag BuildWork bool // -work flag BuildX bool // -x flag ModCacheRW bool // -modcacherw flag ModFile string // -modfile flag CmdName string // "build", "install", "list", "mod tidy", etc. DebugActiongraph string // -debug-actiongraph flag (undocumented, unstable) DebugTrace string // -debug-trace flag // GoPathError is set when GOPATH is not set. it contains an // explanation why GOPATH is unset. GoPathError string )
These are general "build flags" used by build and other commands.
var ( // RawGOEXPERIMENT is the GOEXPERIMENT value set by the user. RawGOEXPERIMENT = envOr("GOEXPERIMENT", buildcfg.DefaultGOEXPERIMENT) // CleanGOEXPERIMENT is the minimal GOEXPERIMENT value needed to reproduce the // experiments enabled by RawGOEXPERIMENT. CleanGOEXPERIMENT = RawGOEXPERIMENT Experiment *buildcfg.ExperimentFlags ExperimentErr error )
Experiment configuration.
var ( GOROOT string GOROOTbin string GOROOTpkg string GOROOTsrc string GOROOT_FINAL string GOBIN = Getenv("GOBIN") GOMODCACHE = envOr("GOMODCACHE", gopathDir("pkg/mod")) // Used in envcmd.MkEnv and build ID computations. GOARM = envOr("GOARM", fmt.Sprint(buildcfg.GOARM)) GO386 = envOr("GO386", buildcfg.GO386) GOAMD64 = envOr("GOAMD64", fmt.Sprintf("%s%d", "v", buildcfg.GOAMD64)) GOMIPS = envOr("GOMIPS", buildcfg.GOMIPS) GOMIPS64 = envOr("GOMIPS64", buildcfg.GOMIPS64) GOPPC64 = envOr("GOPPC64", fmt.Sprintf("%s%d", "power", buildcfg.GOPPC64)) GOWASM = envOr("GOWASM", fmt.Sprint(buildcfg.GOWASM)) GOPROXY = envOr("GOPROXY", "https://proxy.golang.org,direct") GOSUMDB = envOr("GOSUMDB", "sum.golang.org") GOPRIVATE = Getenv("GOPRIVATE") GONOPROXY = envOr("GONOPROXY", GOPRIVATE) GONOSUMDB = envOr("GONOSUMDB", GOPRIVATE) GOINSECURE = Getenv("GOINSECURE") GOVCS = Getenv("GOVCS") )
var CmdEnv []EnvVar
CmdEnv is the new environment for running go tool commands. User binaries (during go test or go run) are run with OrigEnv, not CmdEnv.
var OrigEnv []string
OrigEnv is the original environment of the program at startup.
var SumdbDir = gopathDir("pkg/sumdb")
Functions ¶
func GetArchEnv ¶ added in go1.13
func GetArchEnv() (key, val string)
GetArchEnv returns the name and setting of the GOARCH-specific architecture environment variable. If the current architecture has no GOARCH-specific variable, GetArchEnv returns empty key and value.
func Getenv ¶ added in go1.13
Getenv gets the value for the configuration key. It consults the operating system environment and then the go/env file. If Getenv is called for a key that cannot be set in the go/env file (for example GODEBUG), it panics. This ensures that CanGetenv is accurate, so that 'go env -w' stays in sync with what Getenv can retrieve.