cfg

Imports

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"

Constants & Variables

BuildA var #

These are general "build flags" used by build and other commands.

var BuildA bool

BuildASan var #

These are general "build flags" used by build and other commands.

var BuildASan bool

BuildBuildmode var #

These are general "build flags" used by build and other commands.

var BuildBuildmode string

BuildBuildvcs var #

These are general "build flags" used by build and other commands.

var BuildBuildvcs = "auto"

BuildContext var #

These are general "build flags" used by build and other commands.

var BuildContext = *ast.CallExpr

BuildCover var #

These are general "build flags" used by build and other commands.

var BuildCover bool

BuildCoverMode var #

These are general "build flags" used by build and other commands.

var BuildCoverMode string

BuildCoverPkg var #

These are general "build flags" used by build and other commands.

var BuildCoverPkg []string

BuildJSON var #

These are general "build flags" used by build and other commands.

var BuildJSON bool

BuildLinkshared var #

These are general "build flags" used by build and other commands.

var BuildLinkshared bool

BuildMSan var #

These are general "build flags" used by build and other commands.

var BuildMSan bool

BuildMod var #

These are general "build flags" used by build and other commands.

var BuildMod string

BuildModExplicit var #

These are general "build flags" used by build and other commands.

var BuildModExplicit bool

BuildModReason var #

These are general "build flags" used by build and other commands.

var BuildModReason string

BuildN var #

These are general "build flags" used by build and other commands.

var BuildN bool

BuildO var #

These are general "build flags" used by build and other commands.

var BuildO string

BuildP var #

These are general "build flags" used by build and other commands.

var BuildP = *ast.CallExpr

BuildPGO var #

These are general "build flags" used by build and other commands.

var BuildPGO string

BuildPkgdir var #

These are general "build flags" used by build and other commands.

var BuildPkgdir string

BuildRace var #

These are general "build flags" used by build and other commands.

var BuildRace bool

BuildToolchainCompiler var #

These are general "build flags" used by build and other commands.

var BuildToolchainCompiler func() string

BuildToolchainLinker var #

These are general "build flags" used by build and other commands.

var BuildToolchainLinker func() string

BuildToolchainName var #

These are general "build flags" used by build and other commands.

var BuildToolchainName string

BuildToolexec var #

These are general "build flags" used by build and other commands.

var BuildToolexec []string

BuildTrimpath var #

These are general "build flags" used by build and other commands.

var BuildTrimpath bool

BuildV var #

These are general "build flags" used by build and other commands.

var BuildV bool

BuildWork var #

These are general "build flags" used by build and other commands.

var BuildWork bool

BuildX var #

These are general "build flags" used by build and other commands.

var BuildX bool

CGOChanged var #

These are general "build flags" used by build and other commands.

var CGOChanged bool

CleanGOEXPERIMENT var #

CleanGOEXPERIMENT is the minimal GOEXPERIMENT value needed to reproduce the experiments enabled by RawGOEXPERIMENT.

var CleanGOEXPERIMENT = RawGOEXPERIMENT

CmdEnv var #

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

CmdName var #

These are general "build flags" used by build and other commands.

var CmdName string

DebugActiongraph var #

These are general "build flags" used by build and other commands.

var DebugActiongraph string

DebugRuntimeTrace var #

These are general "build flags" used by build and other commands.

var DebugRuntimeTrace string

DebugTrace var #

These are general "build flags" used by build and other commands.

var DebugTrace string

DefaultPkgConfig const #

const DefaultPkgConfig = `pkg-config`

ExeSuffix var #

Global build parameters (used during package load)

var ExeSuffix = *ast.CallExpr

Experiment var #

Experiment configuration.

var Experiment *buildcfg.ExperimentFlags

ExperimentErr var #

Experiment configuration.

var ExperimentErr error

GO386 var #

var GO386 = *ast.CallExpr

GOAMD64 var #

var GOAMD64 = *ast.CallExpr

GOARM var #

var GOARM = *ast.CallExpr

GOARM64 var #

Used in envcmd.MkEnv and build ID computations.

var GOARM64 = *ast.CallExpr

GOAUTH var #

var GOAUTH = *ast.CallExpr

GOAUTHChanged var #

var GOAUTHChanged

GOBIN var #

var GOBIN = *ast.CallExpr

GOCACHEPROG var #

var GOCACHEPROG = *ast.CallExpr

GOCACHEPROGChanged var #

var GOCACHEPROGChanged

GOFIPS140 var #

var GOFIPS140 = *ast.CallExpr

GOFIPS140Changed var #

var GOFIPS140Changed

GOINSECURE var #

var GOINSECURE = *ast.CallExpr

GOMIPS var #

var GOMIPS = *ast.CallExpr

GOMIPS64 var #

var GOMIPS64 = *ast.CallExpr

GOMODCACHE var #

var GOMODCACHE = *ast.CallExpr

GOMODCACHEChanged var #

var GOMODCACHEChanged

GONOPROXY var #

var GONOPROXY = *ast.CallExpr

GONOPROXYChanged var #

var GONOPROXYChanged

GONOSUMDB var #

var GONOSUMDB = *ast.CallExpr

GONOSUMDBChanged var #

var GONOSUMDBChanged

GOPATHChanged var #

These are general "build flags" used by build and other commands.

var GOPATHChanged bool

GOPPC64 var #

var GOPPC64 = *ast.CallExpr

GOPRIVATE var #

var GOPRIVATE = *ast.CallExpr

GOPROXY var #

var GOPROXY = *ast.CallExpr

GOPROXYChanged var #

var GOPROXYChanged

GORISCV64 var #

var GORISCV64 = *ast.CallExpr

GOROOT var #

var GOROOT string

GOROOTbin var #

Either empty or produced by filepath.Join(GOROOT, …).

var GOROOTbin string

GOROOTpkg var #

var GOROOTpkg string

GOROOTsrc var #

var GOROOTsrc string

GOSUMDB var #

var GOSUMDB = *ast.CallExpr

GOSUMDBChanged var #

var GOSUMDBChanged

GOVCS var #

var GOVCS = *ast.CallExpr

GOWASM var #

var GOWASM = *ast.CallExpr

GoPathError var #

GoPathError is set when GOPATH is not set. it contains an explanation why GOPATH is unset.

var GoPathError string

Goarch var #

Global build parameters (used during package load)

var Goarch = *ast.CallExpr

Goos var #

Global build parameters (used during package load)

var Goos = *ast.CallExpr

ModCacheRW var #

These are general "build flags" used by build and other commands.

var ModCacheRW bool

ModFile var #

These are general "build flags" used by build and other commands.

var ModFile string

ModulesEnabled var #

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 var #

OrigEnv is the original environment of the program at startup.

var OrigEnv []string

RawGOEXPERIMENT var #

RawGOEXPERIMENT is the GOEXPERIMENT value set by the user.

var RawGOEXPERIMENT = *ast.CallExpr

SumdbDir var #

var SumdbDir = *ast.CallExpr

envCache var #

var envCache struct{...}

go386Changed var #

var go386Changed

goAMD64Changed var #

var goAMD64Changed

goARM64Changed var #

Used in envcmd.MkEnv and build ID computations.

var goARM64Changed

goARMChanged var #

var goARMChanged

goMIPS64Changed var #

var goMIPS64Changed

goMIPSChanged var #

var goMIPSChanged

goPPC64Changed var #

var goPPC64Changed

goRISCV64Changed var #

var goRISCV64Changed

goWASMChanged var #

var goWASMChanged

installedGOARCH var #

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

installedGOOS var #

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

Structs

EnvVar struct #

An EnvVar is an environment variable Name=Value.

type EnvVar struct {
Name string
Value string
Changed bool
}

buildXContextKey struct #

type buildXContextKey struct {

}

dirInfo 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
}

Functions

BuildXWriter function #

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 function #

CanGetenv reports whether key is a valid go/env configuration key.

func CanGetenv(key string) bool

DefaultCC function #

func DefaultCC(goos string, goarch string) string

DefaultCXX function #

func DefaultCXX(goos string, goarch string) string

EnvFile function #

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 function #

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 function #

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 function #

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

IsDir method #

func (d *dirInfo) IsDir() bool

ModTime method #

func (d *dirInfo) ModTime() time.Time

Mode method #

func (d *dirInfo) Mode() fs.FileMode

Name method #

func (d *dirInfo) Name() string

SetGOROOT function #

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)

Size method #

func (d *dirInfo) Size() int64

Sys method #

func (d *dirInfo) Sys() any

ToolExeSuffix function #

ToolExeSuffix returns the suffix for executables installed in build.ToolDir.

func ToolExeSuffix() string

WithBuildXWriter function #

WithBuildXWriter returns a Context in which BuildX output is written to given io.Writer.

func WithBuildXWriter(ctx context.Context, xLog io.Writer) context.Context

defaultContext function #

func defaultContext() build.Context

envOr function #

envOr returns Getenv(key) if set, or else def.

func envOr(key string, def string) string

exeSuffix function #

func exeSuffix() string

findGOROOT function #

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

gopath function #

Keep consistent with go/build.defaultGOPATH.

func gopath(ctxt build.Context) string

gopathDir function #

func gopathDir(rel string) string

init function #

func init()

init function #

func init()

initEnvCache function #

func initEnvCache()

isGOROOT function #

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 function #

isSameDir reports whether dir1 and dir2 are the same directory.

func isSameDir(dir1 string, dir2 string) bool

readEnvFile function #

func readEnvFile(file string, source string)

Generated with Arrow