go: github.com/golang/go/src/cmd/go/internal/cfg Index | Files

package cfg

import "github.com/golang/go/src/cmd/go/internal/cfg"

Package cfg holds configuration shared by multiple parts of the go command.

Index

Package Files

cfg.go

Variables

var (
    BuildA                 bool   // -a flag
    BuildBuildmode         string // -buildmode flag
    BuildContext           = defaultContext()
    BuildMod               string             // -mod flag
    BuildI                 bool               // -i flag
    BuildLinkshared        bool               // -linkshared flag
    BuildMSan              bool               // -msan flag
    BuildN                 bool               // -n flag
    BuildO                 string             // -o flag
    BuildP                 = runtime.NumCPU() // -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

    CmdName string // "build", "install", "list", "mod tidy", etc.

    DebugActiongraph string // -debug-actiongraph flag (undocumented, unstable)
)

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

var (
    Goarch = BuildContext.GOARCH
    Goos   = BuildContext.GOOS

    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 (
    GOROOT       = BuildContext.GOROOT
    GOBIN        = Getenv("GOBIN")
    GOROOTbin    = filepath.Join(GOROOT, "bin")
    GOROOTpkg    = filepath.Join(GOROOT, "pkg")
    GOROOTsrc    = filepath.Join(GOROOT, "src")
    GOROOT_FINAL = findGOROOT_FINAL()

    // Used in envcmd.MkEnv and build ID computations.
    GOARM    = envOr("GOARM", fmt.Sprint(objabi.GOARM))
    GO386    = envOr("GO386", objabi.GO386)
    GOMIPS   = envOr("GOMIPS", objabi.GOMIPS)
    GOMIPS64 = envOr("GOMIPS64", objabi.GOMIPS64)
    GOPPC64  = envOr("GOPPC64", fmt.Sprintf("%s%d", "power", objabi.GOPPC64))
    GOWASM   = envOr("GOWASM", fmt.Sprint(objabi.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)
)
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.

func CanGetenv Uses

func CanGetenv(key string) bool

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

func EnvFile Uses

func EnvFile() (string, error)

EnvFile returns the name of the Go environment configuration file.

func GetArchEnv Uses

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 Uses

func Getenv(key string) string

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.

type EnvVar Uses

type EnvVar struct {
    Name  string
    Value string
}

An EnvVar is an environment variable Name=Value.

Package cfg imports 11 packages (graph). Updated 2019-07-22. Refresh now. Tools for package owners.

The go get command cannot install this package because of the following issues: