const gotoolchainModule … const gotoolchainVersion … const targetEnv … const countEnv … const maxSwitch … // FilterEnv returns a copy of env with internal GOTOOLCHAIN environment // variables filtered out. func FilterEnv(env []string) []string { … } var counterErrorsInvalidToolchainInFile … var toolchainTrace … // Select invokes a different Go toolchain if directed by // the GOTOOLCHAIN environment variable or the user's configuration // or go.mod file. // It must be called early in startup. // See https://go.dev/doc/toolchain#select. func Select() { … } var counterSelectExec … var TestVersionSwitch … // Exec invokes the specified Go toolchain or else prints an error and exits the process. // If $GOTOOLCHAIN is set to path or min+path, Exec only considers the PATH // as a source of Go toolchains. Otherwise Exec tries the PATH but then downloads // a toolchain if necessary. func Exec(gotoolchain string) { … } func size(path string) int64 { … } var writeBits … // raceSafeCopy copies the file old to the file new, being careful to ensure // that if multiple go commands call raceSafeCopy(old, new) at the same time, // they don't interfere with each other: both will succeed and return and // later observe the correct content in new. Like in the build cache, we arrange // this by opening new without truncation and then writing the content. // Both go commands can do this simultaneously and will write the same thing // (old never changes content). func raceSafeCopy(old, new string) error { … } // modGoToolchain finds the enclosing go.work or go.mod file // and returns the go version and toolchain lines from the file. // The toolchain line overrides the version line func modGoToolchain() (file, goVers, toolchain string) { … } // goInstallVersion reports whether the command line is go install m@v or go run m@v. // If so, Select must not read the go.mod or go.work file in "auto" or "path" mode. func goInstallVersion() bool { … }