diff options
author | Bryan C. Mills <bcmills@google.com> | 2021-04-28 12:57:55 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2021-04-30 18:05:38 +0000 |
commit | 4063605e0d0ce2ee2603c70a70c3a918adb7369a (patch) | |
tree | 2b6f334a4f924d8432cad11e3edb763f6ca576d1 /src/cmd/go/internal/modload/init.go | |
parent | 8d8abb3b8a80d341ce2d7c6dd3f2a43fd586bed8 (diff) | |
download | go-4063605e0d0ce2ee2603c70a70c3a918adb7369a.tar.gz go-4063605e0d0ce2ee2603c70a70c3a918adb7369a.zip |
cmd/go/internal/modload: avoid loading the full module graph for imports satisfied by lazy roots
For #36460
Change-Id: Ibdbaa893ded772617e22f12db7a0463604db5195
Reviewed-on: https://go-review.googlesource.com/c/go/+/308516
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/init.go')
-rw-r--r-- | src/cmd/go/internal/modload/init.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go index cb206a3dea..f46c58f474 100644 --- a/src/cmd/go/internal/modload/init.go +++ b/src/cmd/go/internal/modload/init.go @@ -1125,6 +1125,22 @@ func keepSums(ctx context.Context, ld *loader, rs *Requirements, which whichSums continue } + if rs.depth == lazy && pkg.mod.Path != "" { + if v, ok := rs.rootSelected(pkg.mod.Path); ok && v == pkg.mod.Version { + // pkg was loaded from a root module, and because the main module is + // lazy we do not check non-root modules for conflicts for packages + // that can be found in roots. So we only need the checksums for the + // root modules that may contain pkg, not all possible modules. + for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) { + if v, ok := rs.rootSelected(prefix); ok && v != "none" { + m := module.Version{Path: prefix, Version: v} + keep[resolveReplacement(m)] = true + } + } + continue + } + } + for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) { if v := mg.Selected(prefix); v != "none" { m := module.Version{Path: prefix, Version: v} |