Imports #
"bytes"
"context"
"fmt"
"go/build"
"internal/buildcfg"
"internal/cfg"
"io"
"io/fs"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
"cmd/go/internal/fsys"
"cmd/internal/pathcache"
"bytes"
"context"
"fmt"
"go/build"
"internal/buildcfg"
"internal/cfg"
"io"
"io/fs"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
"cmd/go/internal/fsys"
"cmd/internal/pathcache"
These are general "build flags" used by build and other commands.
var BuildA boolThese are general "build flags" used by build and other commands.
var BuildASan boolThese are general "build flags" used by build and other commands.
var BuildBuildmode stringThese are general "build flags" used by build and other commands.
var BuildBuildvcs = "auto"These are general "build flags" used by build and other commands.
var BuildContext = *ast.CallExprThese are general "build flags" used by build and other commands.
var BuildCover boolThese are general "build flags" used by build and other commands.
var BuildCoverMode stringThese are general "build flags" used by build and other commands.
var BuildCoverPkg []stringThese are general "build flags" used by build and other commands.
var BuildJSON boolThese are general "build flags" used by build and other commands.
var BuildLinkshared boolThese are general "build flags" used by build and other commands.
var BuildMSan boolThese are general "build flags" used by build and other commands.
var BuildMod stringThese are general "build flags" used by build and other commands.
var BuildModExplicit boolThese are general "build flags" used by build and other commands.
var BuildModReason stringThese are general "build flags" used by build and other commands.
var BuildN boolThese are general "build flags" used by build and other commands.
var BuildO stringThese are general "build flags" used by build and other commands.
var BuildP = *ast.CallExprThese are general "build flags" used by build and other commands.
var BuildPGO stringThese are general "build flags" used by build and other commands.
var BuildPkgdir stringThese are general "build flags" used by build and other commands.
var BuildRace boolThese are general "build flags" used by build and other commands.
var BuildToolchainCompiler func() stringThese are general "build flags" used by build and other commands.
var BuildToolchainLinker func() stringThese are general "build flags" used by build and other commands.
var BuildToolchainName stringThese are general "build flags" used by build and other commands.
var BuildToolexec []stringThese are general "build flags" used by build and other commands.
var BuildTrimpath boolThese are general "build flags" used by build and other commands.
var BuildV boolThese are general "build flags" used by build and other commands.
var BuildWork boolThese are general "build flags" used by build and other commands.
var BuildX boolThese are general "build flags" used by build and other commands.
var CGOChanged boolCleanGOEXPERIMENT is the minimal GOEXPERIMENT value needed to reproduce the experiments enabled by RawGOEXPERIMENT.
var CleanGOEXPERIMENT = RawGOEXPERIMENTCmdEnv is the new environment for running go tool commands. User binaries (during go test or go run) are run with OrigEnv, not CmdEnv.
var CmdEnv []EnvVarThese are general "build flags" used by build and other commands.
var CmdName stringThese are general "build flags" used by build and other commands.
var DebugActiongraph stringThese are general "build flags" used by build and other commands.
var DebugRuntimeTrace stringThese are general "build flags" used by build and other commands.
var DebugTrace stringconst DefaultPkgConfig = `pkg-config`Global build parameters (used during package load)
var ExeSuffix = *ast.CallExprExperiment configuration.
var Experiment *buildcfg.ExperimentFlagsExperiment configuration.
var ExperimentErr errorvar GO386 = *ast.CallExprvar GOAMD64 = *ast.CallExprvar GOARM = *ast.CallExprUsed in envcmd.MkEnv and build ID computations.
var GOARM64 = *ast.CallExprvar GOAUTH = *ast.CallExprvar GOAUTHChangedvar GOBIN = *ast.CallExprvar GOCACHEPROG = *ast.CallExprvar GOCACHEPROGChangedvar GOFIPS140 = *ast.CallExprvar GOFIPS140Changedvar GOINSECURE = *ast.CallExprvar GOMIPS = *ast.CallExprvar GOMIPS64 = *ast.CallExprvar GOMODCACHE = *ast.CallExprvar GOMODCACHEChangedvar GONOPROXY = *ast.CallExprvar GONOPROXYChangedvar GONOSUMDB = *ast.CallExprvar GONOSUMDBChangedThese are general "build flags" used by build and other commands.
var GOPATHChanged boolvar GOPPC64 = *ast.CallExprvar GOPRIVATE = *ast.CallExprvar GOPROXY = *ast.CallExprvar GOPROXYChangedvar GORISCV64 = *ast.CallExprvar GOROOT stringEither empty or produced by filepath.Join(GOROOT, …).
var GOROOTbin stringvar GOROOTpkg stringvar GOROOTsrc stringvar GOSUMDB = *ast.CallExprvar GOSUMDBChangedvar GOVCS = *ast.CallExprvar GOWASM = *ast.CallExprGoPathError is set when GOPATH is not set. it contains an explanation why GOPATH is unset.
var GoPathError stringGlobal build parameters (used during package load)
var Goarch = *ast.CallExprGlobal build parameters (used during package load)
var Goos = *ast.CallExprThese are general "build flags" used by build and other commands.
var ModCacheRW boolThese are general "build flags" used by build and other commands.
var ModFile stringModulesEnabled 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.
var ModulesEnabled boolOrigEnv is the original environment of the program at startup.
var OrigEnv []stringRawGOEXPERIMENT is the GOEXPERIMENT value set by the user.
var RawGOEXPERIMENT = *ast.CallExprvar SumdbDir = *ast.CallExprvar envCache struct{...}var go386Changedvar goAMD64ChangedUsed in envcmd.MkEnv and build ID computations.
var goARM64Changedvar goARMChangedvar goMIPS64Changedvar goMIPSChangedvar goPPC64Changedvar goRISCV64Changedvar goWASMChangedConfiguration for tools installed to GOROOT/bin. Normally these match runtime.GOOS and runtime.GOARCH, but when testing a cross-compiled cmd/go they will indicate the GOOS and GOARCH of the installed cmd/go rather than the test binary.
var installedGOARCH stringConfiguration for tools installed to GOROOT/bin. Normally these match runtime.GOOS and runtime.GOARCH, but when testing a cross-compiled cmd/go they will indicate the GOOS and GOARCH of the installed cmd/go rather than the test binary.
var installedGOOS stringAn EnvVar is an environment variable Name=Value.
type EnvVar struct {
Name string
Value string
Changed bool
}type buildXContextKey struct {
}A dirInfo implements fs.FileInfo from fs.DirEntry. We know that go/build doesn't use the non-DirEntry parts, so we can panic instead of doing difficult work.
type dirInfo struct {
dir fs.DirEntry
}BuildXWriter returns nil if BuildX is false, or the writer to which BuildX output should be written otherwise.
func BuildXWriter(ctx context.Context) (io.Writer, bool)CanGetenv reports whether key is a valid go/env configuration key.
func CanGetenv(key string) boolfunc DefaultCC(goos string, goarch string) stringfunc DefaultCXX(goos string, goarch string) stringEnvFile returns the name of the Go environment configuration file, and reports whether the effective value differs from the default.
func EnvFile() (string, bool, error)EnvOrAndChanged returns the environment variable value and reports whether it differs from the default value.
func EnvOrAndChanged(name string, def string) (v string, changed bool)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 GetArchEnv() (key string, val string, changed bool)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.
func Getenv(key string) stringfunc (d *dirInfo) IsDir() boolfunc (d *dirInfo) ModTime() time.Timefunc (d *dirInfo) Mode() fs.FileModefunc (d *dirInfo) Name() stringSetGOROOT sets GOROOT and associated variables to the given values. If isTestGo is true, build.ToolDir is set based on the TESTGO_GOHOSTOS and TESTGO_GOHOSTARCH environment variables instead of runtime.GOOS and runtime.GOARCH.
func SetGOROOT(goroot string, isTestGo bool)func (d *dirInfo) Size() int64func (d *dirInfo) Sys() anyToolExeSuffix returns the suffix for executables installed in build.ToolDir.
func ToolExeSuffix() stringWithBuildXWriter returns a Context in which BuildX output is written to given io.Writer.
func WithBuildXWriter(ctx context.Context, xLog io.Writer) context.Contextfunc defaultContext() build.ContextenvOr returns Getenv(key) if set, or else def.
func envOr(key string, def string) stringfunc exeSuffix() stringfindGOROOT returns the GOROOT value, using either an explicitly provided environment variable, a GOROOT that contains the current os.Executable value, or else the GOROOT that the binary was built with from runtime.GOROOT(). There is a copy of this code in x/tools/cmd/godoc/goroot.go.
func findGOROOT(env string) stringKeep consistent with go/build.defaultGOPATH.
func gopath(ctxt build.Context) stringfunc gopathDir(rel string) stringfunc init()func init()func initEnvCache()isGOROOT reports whether path looks like a GOROOT. It does this by looking for the path/pkg/tool directory, which is necessary for useful operation of the cmd/go tool, and is not typically present in a GOPATH. There is a copy of this code in x/tools/cmd/godoc/goroot.go.
func isGOROOT(path string) boolisSameDir reports whether dir1 and dir2 are the same directory.
func isSameDir(dir1 string, dir2 string) boolfunc readEnvFile(file string, source string)Generated with Arrow