diff options
author | Bryan C. Mills <bcmills@google.com> | 2021-01-28 10:18:24 -0500 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2021-02-18 17:57:36 +0000 |
commit | a76efea1fe18045ecb8d1cf2c1104208e636fbae (patch) | |
tree | 11467b01350160cdcd84e2b53bc627b5e91a1d4e /src/cmd/go/internal/mvs/mvs.go | |
parent | 609d82b28992e6a7fac48add680f170c4eee83fd (diff) | |
download | go-a76efea1fe18045ecb8d1cf2c1104208e636fbae.tar.gz go-a76efea1fe18045ecb8d1cf2c1104208e636fbae.zip |
cmd/go/internal/mvs: don't emit duplicates from Req
Req is supposed to return “a minimal requirement list”
that includes each of the module paths listed in base.
Currently, if base contains duplicates Req emits duplicates,
and a list containing duplicates is certainly not minimal.
That, in turn, requires callers to be careful to deduplicate the base
slice, and there are multiple callers that are already quite
complicated to reason about even without the added complication of
deduplicating slices.
For #36460
Change-Id: I391a1dc0641fe1dd424c16b7a1082da0d00c7292
Reviewed-on: https://go-review.googlesource.com/c/go/+/287632
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>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/mvs/mvs.go')
-rw-r--r-- | src/cmd/go/internal/mvs/mvs.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/go/internal/mvs/mvs.go b/src/cmd/go/internal/mvs/mvs.go index b630b610f1..f016d8ff15 100644 --- a/src/cmd/go/internal/mvs/mvs.go +++ b/src/cmd/go/internal/mvs/mvs.go @@ -293,10 +293,15 @@ func Req(target module.Version, base []string, reqs Reqs) ([]module.Version, err } // First walk the base modules that must be listed. var min []module.Version + haveBase := map[string]bool{} for _, path := range base { + if haveBase[path] { + continue + } m := module.Version{Path: path, Version: max[path]} min = append(min, m) walk(m) + haveBase[path] = true } // Now the reverse postorder to bring in anything else. for i := len(postorder) - 1; i >= 0; i-- { |