github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/toolchain/select.go (about)

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package toolchain implements dynamic switching of Go toolchains.
     6  package toolchain
     7  
     8  // FilterEnv returns a copy of env with internal GOTOOLCHAIN environment
     9  // variables filtered out.
    10  func FilterEnv(env []string) []string
    11  
    12  // Select invokes a different Go toolchain if directed by
    13  // the GOTOOLCHAIN environment variable or the user's configuration
    14  // or go.mod file.
    15  // It must be called early in startup.
    16  // See https://go.dev/doc/toolchain#select.
    17  func Select()
    18  
    19  // TestVersionSwitch is set in the test go binary to the value in $TESTGO_VERSION_SWITCH.
    20  // Valid settings are:
    21  //
    22  //	"switch" - simulate version switches by reinvoking the test go binary with a different TESTGO_VERSION.
    23  //	"mismatch" - like "switch" but forget to set TESTGO_VERSION, so it looks like we invoked a mismatched toolchain
    24  //	"loop" - like "mismatch" but forget the target check, causing a toolchain switching loop
    25  var TestVersionSwitch string
    26  
    27  // Exec invokes the specified Go toolchain or else prints an error and exits the process.
    28  // If $GOTOOLCHAIN is set to path or min+path, Exec only considers the PATH
    29  // as a source of Go toolchains. Otherwise Exec tries the PATH but then downloads
    30  // a toolchain if necessary.
    31  func Exec(gotoolchain string)