aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/vendor.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2020-03-13 16:46:51 -0400
committerBryan C. Mills <bcmills@google.com>2020-08-24 20:22:16 +0000
commit5c76382762cfc34b7a7678668460f127fec4a35b (patch)
tree1b87d124fa5d56eca5ea599bdfbd3346eedf6840 /src/cmd/go/internal/modload/vendor.go
parent94953d3e5928c8a577bad7911aabbf627269ef77 (diff)
downloadgo-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.go4
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 {