import (
"context"
+ "errors"
"fmt"
"go/build"
"io/fs"
"cmd/go/internal/base"
"cmd/go/internal/cfg"
"cmd/go/internal/gover"
- "cmd/go/internal/modcmd"
"cmd/go/internal/modfetch"
"cmd/go/internal/modload"
"cmd/go/internal/run"
// Download and unpack toolchain module into module cache.
// Note that multiple go commands might be doing this at the same time,
// and that's OK: the module cache handles that case correctly.
- m := &modcmd.ModuleJSON{
+ m := module.Version{
Path: gotoolchainModule,
Version: gotoolchainVersion + "-" + gotoolchain + "." + runtime.GOOS + "-" + runtime.GOARCH,
}
- modcmd.DownloadModule(context.Background(), m)
- if m.Error != "" {
- if strings.Contains(m.Error, ".info: 404") {
+ dir, err := modfetch.Download(context.Background(), m)
+ if err != nil {
+ if errors.Is(err, fs.ErrNotExist) {
base.Fatalf("download %s for %s/%s: toolchain not available", gotoolchain, runtime.GOOS, runtime.GOARCH)
}
- base.Fatalf("download %s: %v", gotoolchain, m.Error)
+ base.Fatalf("download %s: %v", gotoolchain, err)
}
// On first use after download, set the execute bits on the commands
// so that we can run them. Note that multiple go commands might be
// doing this at the same time, but if so no harm done.
- dir := m.Dir
if runtime.GOOS != "windows" {
info, err := os.Stat(filepath.Join(dir, "bin/go"))
if err != nil {