mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go/internal/toolchain: remove references to modfetch.Fetcher_
This commit removes references to the global modfetch.Fetcher_ variable from the toolchain package. Change-Id: Id366bec88e5904098b90371ec103f92d402174d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/724248 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
46d5e3ea0e
commit
08bf23cb97
2 changed files with 15 additions and 11 deletions
|
|
@ -25,7 +25,6 @@ import (
|
|||
"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"
|
||||
|
|
@ -86,8 +85,10 @@ func FilterEnv(env []string) []string {
|
|||
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
|
||||
|
|
@ -360,7 +361,7 @@ func Exec(s *modload.State, gotoolchain string) {
|
|||
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)
|
||||
|
|
@ -380,7 +381,7 @@ func Exec(s *modload.State, gotoolchain string) {
|
|||
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) {
|
||||
|
|
@ -399,7 +400,7 @@ func Exec(s *modload.State, gotoolchain 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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ func (s *Switcher) Switch(ctx context.Context) {
|
|||
}
|
||||
|
||||
// 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)
|
||||
|
|
@ -130,8 +130,11 @@ func SwitchOrFatal(loaderstate *modload.State, ctx context.Context, err error) {
|
|||
// 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
|
||||
}
|
||||
|
|
@ -143,10 +146,10 @@ func NewerToolchain(ctx context.Context, version string) (string, error) {
|
|||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue