aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/buildlist.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-04-09 00:39:25 -0400
committerBryan C. Mills <bcmills@google.com>2021-04-09 18:49:05 +0000
commitc3faff7f2d62a81d612ed46204c2e6bd5f460f01 (patch)
treeeba8166108670fee0a77dae58b46092a19b8d301 /src/cmd/go/internal/modload/buildlist.go
parent814c5ff13810e800aeb67fd0371e21984d4d2c64 (diff)
downloadgo-c3faff7f2d62a81d612ed46204c2e6bd5f460f01.tar.gz
go-c3faff7f2d62a81d612ed46204c2e6bd5f460f01.zip
cmd/go/internal/modload: change mvsReqs to store roots instead of a full build list
The mvsReqs implementation has always been a bit ambivalent about whether the root requirements return the full build list, just the direct requirements, or some hybrid of the two. However, a full build list always requires the Target module as the first entry, and it's easer to remove a redundant leading element from a slice than to add one. Changing the mvsReqs field to contain arbitrary roots instead of a full build list eliminates the need to add redundant elements, at the cost of needing to remove redundant elements in more places. For #36460 Change-Id: Idd4c2d6bc7b66f67680037dab1fb9c2d1b40ab93 Reviewed-on: https://go-review.googlesource.com/c/go/+/308811 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/buildlist.go')
-rw-r--r--src/cmd/go/internal/modload/buildlist.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/cmd/go/internal/modload/buildlist.go b/src/cmd/go/internal/modload/buildlist.go
index a1ac7b22b7..ad138887a0 100644
--- a/src/cmd/go/internal/modload/buildlist.go
+++ b/src/cmd/go/internal/modload/buildlist.go
@@ -492,7 +492,7 @@ func editRequirements(ctx context.Context, rs *Requirements, add, mustSelect []m
// remove roots.)
}
- min, err := mvs.Req(Target, rootPaths, &mvsReqs{buildList: final})
+ min, err := mvs.Req(Target, rootPaths, &mvsReqs{roots: final[1:]})
if err != nil {
return nil, false, err
}
@@ -610,7 +610,7 @@ func updateRoots(ctx context.Context, depth modDepth, direct map[string]bool, pk
// dependencies, then we can't reliably compute a minimal subset of them.
return rs, err
}
- keep = mg.BuildList()
+ keep = mg.BuildList()[1:]
for _, root := range rs.rootModules {
// If the selected version of the root is the same as what was already
@@ -625,7 +625,6 @@ func updateRoots(ctx context.Context, depth modDepth, direct map[string]bool, pk
}
}
} else {
- keep = append(keep, Target)
kept := map[module.Version]bool{Target: true}
for _, pkg := range pkgs {
if pkg.mod.Path != "" && !kept[pkg.mod] {
@@ -691,7 +690,7 @@ func updateRoots(ctx context.Context, depth modDepth, direct map[string]bool, pk
return rs, nil
}
- min, err := mvs.Req(Target, rootPaths, &mvsReqs{buildList: keep})
+ min, err := mvs.Req(Target, rootPaths, &mvsReqs{roots: keep})
if err != nil {
return rs, err
}