"cmd/go/internal/base"
"cmd/go/internal/cfg"
"cmd/go/internal/gover"
- "cmd/go/internal/modfetch"
"cmd/go/internal/modload"
"cmd/go/internal/run"
"cmd/go/internal/work"
return out
}
-var counterErrorsInvalidToolchainInFile = counter.New("go/errors:invalid-toolchain-in-file")
-var toolchainTrace = godebug.New("#toolchaintrace").Value() == "1"
+var (
+ counterErrorsInvalidToolchainInFile = counter.New("go/errors:invalid-toolchain-in-file")
+ toolchainTrace = godebug.New("#toolchaintrace").Value() == "1"
+)
// Select invokes a different Go toolchain if directed by
// the GOTOOLCHAIN environment variable or the user's configuration
Path: gotoolchainModule,
Version: gotoolchainVersion + "-" + gotoolchain + "." + runtime.GOOS + "-" + runtime.GOARCH,
}
- dir, err := modfetch.Fetcher_.Download(context.Background(), m)
+ dir, err := s.Fetcher().Download(context.Background(), m)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
toolVers := gover.FromToolchain(gotoolchain)
if err != nil {
base.Fatalf("download %s: %v", gotoolchain, err)
}
- if info.Mode()&0111 == 0 {
+ if info.Mode()&0o111 == 0 {
// allowExec sets the exec permission bits on all files found in dir if pattern is the empty string,
// or only those files that match the pattern if it's non-empty.
allowExec := func(dir, pattern string) {
if err != nil {
return err
}
- if err := os.Chmod(path, info.Mode()&0777|0111); err != nil {
+ if err := os.Chmod(path, info.Mode()&0o777|0o111); err != nil {
return err
}
}
}
// Switch to newer Go toolchain if necessary and possible.
- tv, err := NewerToolchain(ctx, s.TooNew.GoVersion)
+ tv, err := NewerToolchain(ctx, s.loaderstate.Fetcher(), s.TooNew.GoVersion)
if err != nil {
for _, err := range s.Errors {
base.Error(err)
// If the latest major release is 1.N.0, we use the latest patch release of 1.(N-1) if that's >= version.
// Otherwise we use the latest 1.N if that's allowed.
// Otherwise we use the latest release.
-func NewerToolchain(ctx context.Context, version string) (string, error) {
- fetch := autoToolchains
+func NewerToolchain(ctx context.Context, f *modfetch.Fetcher, version string) (string, error) {
+ fetch := func(ctx context.Context) ([]string, error) {
+ return autoToolchains(ctx, f)
+ }
+
if !HasAuto() {
fetch = pathToolchains
}
}
// autoToolchains returns the list of toolchain versions available to GOTOOLCHAIN=auto or =min+auto mode.
-func autoToolchains(ctx context.Context) ([]string, error) {
+func autoToolchains(ctx context.Context, f *modfetch.Fetcher) ([]string, error) {
var versions *modfetch.Versions
err := modfetch.TryProxies(func(proxy string) error {
- v, err := modfetch.Fetcher_.Lookup(ctx, proxy, "go").Versions(ctx, "")
+ v, err := f.Lookup(ctx, proxy, "go").Versions(ctx, "")
if err != nil {
return err
}