diff options
author | Bryan C. Mills <bcmills@google.com> | 2020-03-13 16:46:51 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2020-08-24 20:22:16 +0000 |
commit | 5c76382762cfc34b7a7678668460f127fec4a35b (patch) | |
tree | 1b87d124fa5d56eca5ea599bdfbd3346eedf6840 /src/cmd/go/internal/modload/vendor.go | |
parent | 94953d3e5928c8a577bad7911aabbf627269ef77 (diff) | |
download | go-5c76382762cfc34b7a7678668460f127fec4a35b.tar.gz go-5c76382762cfc34b7a7678668460f127fec4a35b.zip |
cmd/go/internal/modload: add a "v" prefix to the indexed go version
This allows semver-based comparisons of the version without additional allocations.
Also comment on the reason for the loops that iterate over modFile instead.
(I was reading the vendor code in order to add the lazy-loading version check,
and this section was a bit unclear to me.)
For #36460
Change-Id: I11559d81ffb4eba0e4e10e6fa3c01990b11f9180
Reviewed-on: https://go-review.googlesource.com/c/go/+/240622
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/vendor.go')
-rw-r--r-- | src/cmd/go/internal/modload/vendor.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modload/vendor.go b/src/cmd/go/internal/modload/vendor.go index 71f68efbcc..9f34b829fc 100644 --- a/src/cmd/go/internal/modload/vendor.go +++ b/src/cmd/go/internal/modload/vendor.go @@ -133,7 +133,7 @@ func checkVendorConsistency() { readVendorList() pre114 := false - if modFile.Go == nil || semver.Compare("v"+modFile.Go.Version, "v1.14") < 0 { + if semver.Compare(index.goVersionV, "v1.14") < 0 { // Go versions before 1.14 did not include enough information in // vendor/modules.txt to check for consistency. // If we know that we're on an earlier version, relax the consistency check. @@ -150,6 +150,8 @@ func checkVendorConsistency() { } } + // Iterate over the Require directives in their original (not indexed) order + // so that the errors match the original file. for _, r := range modFile.Require { if !vendorMeta[r.Mod].Explicit { if pre114 { |