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 bool
These are general "build flags" used by build and other commands.
var BuildASan bool
These are general "build flags" used by build and other commands.
var BuildBuildmode string
These 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.CallExpr
These are general "build flags" used by build and other commands.
var BuildCover bool
These are general "build flags" used by build and other commands.
var BuildCoverMode string
These are general "build flags" used by build and other commands.
var BuildCoverPkg []string
These are general "build flags" used by build and other commands.
var BuildJSON bool
These are general "build flags" used by build and other commands.
var BuildLinkshared bool
These are general "build flags" used by build and other commands.
var BuildMSan bool
These are general "build flags" used by build and other commands.
var BuildMod string
These are general "build flags" used by build and other commands.
var BuildModExplicit bool
These are general "build flags" used by build and other commands.
var BuildModReason string
These are general "build flags" used by build and other commands.
var BuildN bool
These are general "build flags" used by build and other commands.
var BuildO string
These are general "build flags" used by build and other commands.
var BuildP = *ast.CallExpr
These are general "build flags" used by build and other commands.
var BuildPGO string
These are general "build flags" used by build and other commands.
var BuildPkgdir string
These are general "build flags" used by build and other commands.
var BuildRace bool
These are general "build flags" used by build and other commands.
var BuildToolchainCompiler func() string
These are general "build flags" used by build and other commands.
var BuildToolchainLinker func() string
These are general "build flags" used by build and other commands.
var BuildToolchainName string
These are general "build flags" used by build and other commands.
var BuildToolexec []string
These are general "build flags" used by build and other commands.
var BuildTrimpath bool
These are general "build flags" used by build and other commands.
var BuildV bool
These are general "build flags" used by build and other commands.
var BuildWork bool
These are general "build flags" used by build and other commands.
var BuildX bool
These are general "build flags" used by build and other commands.
var CGOChanged bool
CleanGOEXPERIMENT is the minimal GOEXPERIMENT value needed to reproduce the experiments enabled by RawGOEXPERIMENT.
var CleanGOEXPERIMENT = RawGOEXPERIMENT
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 CmdEnv []EnvVar
These are general "build flags" used by build and other commands.
var CmdName string
These are general "build flags" used by build and other commands.
var DebugActiongraph string
These are general "build flags" used by build and other commands.
var DebugRuntimeTrace string
These are general "build flags" used by build and other commands.
var DebugTrace string
const DefaultPkgConfig = `pkg-config`
Global build parameters (used during package load)
var ExeSuffix = *ast.CallExpr
Experiment configuration.
var Experiment *buildcfg.ExperimentFlags
Experiment configuration.
var ExperimentErr error
var GO386 = *ast.CallExpr
var GOAMD64 = *ast.CallExpr
var GOARM = *ast.CallExpr
Used in envcmd.MkEnv and build ID computations.
var GOARM64 = *ast.CallExpr
var GOAUTH = *ast.CallExpr
var GOAUTHChanged
var GOBIN = *ast.CallExpr
var GOCACHEPROG = *ast.CallExpr
var GOCACHEPROGChanged
var GOFIPS140 = *ast.CallExpr
var GOFIPS140Changed
var GOINSECURE = *ast.CallExpr
var GOMIPS = *ast.CallExpr
var GOMIPS64 = *ast.CallExpr
var GOMODCACHE = *ast.CallExpr
var GOMODCACHEChanged
var GONOPROXY = *ast.CallExpr
var GONOPROXYChanged
var GONOSUMDB = *ast.CallExpr
var GONOSUMDBChanged
These are general "build flags" used by build and other commands.
var GOPATHChanged bool
var GOPPC64 = *ast.CallExpr
var GOPRIVATE = *ast.CallExpr
var GOPROXY = *ast.CallExpr
var GOPROXYChanged
var GORISCV64 = *ast.CallExpr
var GOROOT string
Either empty or produced by filepath.Join(GOROOT, …).
var GOROOTbin string
var GOROOTpkg string
var GOROOTsrc string
var GOSUMDB = *ast.CallExpr
var GOSUMDBChanged
var GOVCS = *ast.CallExpr
var GOWASM = *ast.CallExpr
GoPathError is set when GOPATH is not set. it contains an explanation why GOPATH is unset.
var GoPathError string
Global build parameters (used during package load)
var Goarch = *ast.CallExpr
Global build parameters (used during package load)
var Goos = *ast.CallExpr
These are general "build flags" used by build and other commands.
var ModCacheRW bool
These are general "build flags" used by build and other commands.
var ModFile string
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.
var ModulesEnabled bool
OrigEnv is the original environment of the program at startup.
var OrigEnv []string
RawGOEXPERIMENT is the GOEXPERIMENT value set by the user.
var RawGOEXPERIMENT = *ast.CallExpr
var SumdbDir = *ast.CallExpr
var envCache struct{...}
var go386Changed
var goAMD64Changed
Used in envcmd.MkEnv and build ID computations.
var goARM64Changed
var goARMChanged
var goMIPS64Changed
var goMIPSChanged
var goPPC64Changed
var goRISCV64Changed
var goWASMChanged
Configuration 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 string
Configuration 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 string
An 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) bool
func DefaultCC(goos string, goarch string) string
func DefaultCXX(goos string, goarch string) string
EnvFile 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) string
func (d *dirInfo) IsDir() bool
func (d *dirInfo) ModTime() time.Time
func (d *dirInfo) Mode() fs.FileMode
func (d *dirInfo) Name() string
SetGOROOT 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() int64
func (d *dirInfo) Sys() any
ToolExeSuffix returns the suffix for executables installed in build.ToolDir.
func ToolExeSuffix() string
WithBuildXWriter returns a Context in which BuildX output is written to given io.Writer.
func WithBuildXWriter(ctx context.Context, xLog io.Writer) context.Context
func defaultContext() build.Context
envOr returns Getenv(key) if set, or else def.
func envOr(key string, def string) string
func exeSuffix() string
findGOROOT 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) string
Keep consistent with go/build.defaultGOPATH.
func gopath(ctxt build.Context) string
func gopathDir(rel string) string
func 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) bool
isSameDir reports whether dir1 and dir2 are the same directory.
func isSameDir(dir1 string, dir2 string) bool
func readEnvFile(file string, source string)
Generated with Arrow