diff options
author | Jay Conrod <jayconrod@google.com> | 2020-05-14 15:03:26 -0400 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2020-06-01 18:13:51 +0000 |
commit | 8be0de1e7e1f1c3f0d2b4b1ab2b4bc96377a3772 (patch) | |
tree | 8e6ef99c17b6271f346d6cd0532c5d49391be20d /src/cmd/go/internal/modload/mvs.go | |
parent | f8662a5a96698c5fcf3a77f692e425c7b857e681 (diff) | |
download | go-8be0de1e7e1f1c3f0d2b4b1ab2b4bc96377a3772.tar.gz go-8be0de1e7e1f1c3f0d2b4b1ab2b4bc96377a3772.zip |
cmd/go/internal/modload: document mvsReqs.Max
The version "" denotes the main module, which has no version. The
mvs.Reqs interface documentation hints this is allowed, but it's not
obvious from the implementation in modload.mvsReqs.Max.
Also, replace a related TODO with a comment in mvs.Downgrade.
Fixes #39042
Change-Id: I11e10908c9b3d8c2283eaa5c04bd8e1b936851fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/234003
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/mvs.go')
-rw-r--r-- | src/cmd/go/internal/modload/mvs.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modload/mvs.go b/src/cmd/go/internal/modload/mvs.go index a4bdf3ee00..5dd009d31d 100644 --- a/src/cmd/go/internal/modload/mvs.go +++ b/src/cmd/go/internal/modload/mvs.go @@ -157,6 +157,12 @@ func (r *mvsReqs) required(mod module.Version) ([]module.Version, error) { return r.modFileToList(f), nil } +// Max returns the maximum of v1 and v2 according to semver.Compare. +// +// As a special case, the version "" is considered higher than all other +// versions. The main module (also known as the target) has no version and must +// be chosen over other versions of the same module in the module dependency +// graph. func (*mvsReqs) Max(v1, v2 string) string { if v1 != "" && semver.Compare(v1, v2) == -1 { return v2 |