]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modload: remove the needSum argument from the fetch function
authorBryan C. Mills <bcmills@google.com>
Fri, 7 Oct 2022 18:05:56 +0000 (14:05 -0400)
committerGopher Robot <gobot@golang.org>
Fri, 7 Oct 2022 18:28:14 +0000 (18:28 +0000)
With moduleHasRootPackage eliminated in the previous CL, needSum is
now invariantly true at all call sites.

Change-Id: I00e44117e545ea0d3de82604dfa018b013ab8f0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/440296
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/go/internal/modload/build.go
src/cmd/go/internal/modload/import.go
src/cmd/go/internal/modload/query.go
src/cmd/go/internal/modload/search.go

index 14ba83c9c9c1a798e7692cd9e3b2294ddebe774d..9381acf7983dc64ec946a2196d22285cfece43c3 100644 (file)
@@ -76,8 +76,7 @@ func PackageModRoot(ctx context.Context, pkgpath string) string {
        if !ok {
                return ""
        }
-       const needSum = true
-       root, _, err := fetch(ctx, m, needSum)
+       root, _, err := fetch(ctx, m)
        if err != nil {
                return ""
        }
index f2c7592a284e5796160f20d60cf41a06df2510eb..d1ac274a28e8dac5c5ddeda35b984dd717749b8d 100644 (file)
@@ -355,8 +355,7 @@ func importFromModules(ctx context.Context, path string, rs *Requirements, mg *M
                        }
                        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.
@@ -483,8 +482,7 @@ func queryImport(ctx context.Context, path string, rs *Requirements) (module.Ver
                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}
@@ -676,14 +674,9 @@ func dirInModule(path, mpath, mdir string, isLocal bool) (dir string, haveGoFile
 // 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
        }
@@ -713,7 +706,7 @@ func fetch(ctx context.Context, mod module.Version, needSum bool) (dir string, i
                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{})
        }
 
index 2d6ba8e5a059ade78d3f954f2fa03297020c51d3..c74c9b32e2dd56e02258d29c551744295f3a4a4d 100644 (file)
@@ -729,8 +729,7 @@ func QueryPattern(ctx context.Context, pattern, query string, current func(strin
                                return r, err
                        }
                        r.Mod.Version = r.Rev.Version
-                       needSum := true
-                       root, isLocal, err := fetch(ctx, r.Mod, needSum)
+                       root, isLocal, err := fetch(ctx, r.Mod)
                        if err != nil {
                                return r, err
                        }
index 7fc7aa4dd78be4194aec0b8408dc990c920ffbaa..1da46a4b0532eb574e3d5c19e61c3aa23bbed879 100644 (file)
@@ -188,8 +188,7 @@ func matchPackages(ctx context.Context, m *search.Match, tags map[string]bool, f
                        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
@@ -279,8 +278,7 @@ func MatchInModule(ctx context.Context, pattern string, m module.Version, tags m
                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