}
m := module.Version{Path: prefix, Version: v}
- needSum := true
- root, isLocal, err := fetch(ctx, m, needSum)
+ root, isLocal, err := fetch(ctx, m)
if err != nil {
if sumErr := (*sumMissingError)(nil); errors.As(err, &sumErr) {
// We are missing a sum needed to fetch a module in the build list.
return len(mods[i].Path) > len(mods[j].Path)
})
for _, m := range mods {
- needSum := true
- root, isLocal, err := fetch(ctx, m, needSum)
+ root, isLocal, err := fetch(ctx, m)
if err != nil {
if sumErr := (*sumMissingError)(nil); errors.As(err, &sumErr) {
return module.Version{}, &ImportMissingSumError{importPath: path}
// fetch downloads the given module (or its replacement)
// and returns its location.
//
-// needSum indicates whether the module may be downloaded in readonly mode
-// without a go.sum entry. It should only be false for modules fetched
-// speculatively (for example, for incompatible version filtering). The sum
-// will still be verified normally.
-//
// The isLocal return value reports whether the replacement,
// if any, is local to the filesystem.
-func fetch(ctx context.Context, mod module.Version, needSum bool) (dir string, isLocal bool, err error) {
+func fetch(ctx context.Context, mod module.Version) (dir string, isLocal bool, err error) {
if modRoot := MainModules.ModRoot(mod); modRoot != "" {
return modRoot, true, nil
}
mod = r
}
- if HasModRoot() && cfg.BuildMod == "readonly" && !inWorkspaceMode() && needSum && !modfetch.HaveSum(mod) {
+ if HasModRoot() && cfg.BuildMod == "readonly" && !inWorkspaceMode() && !modfetch.HaveSum(mod) {
return "", false, module.VersionError(mod, &sumMissingError{})
}
isLocal = true
} else {
var err error
- const needSum = true
- root, isLocal, err = fetch(ctx, mod, needSum)
+ root, isLocal, err = fetch(ctx, mod)
if err != nil {
m.AddError(err)
continue
return match
}
- const needSum = true
- root, isLocal, err := fetch(ctx, m, needSum)
+ root, isLocal, err := fetch(ctx, m)
if err != nil {
match.Errs = []error{err}
return match