diff options
author | Bryan C. Mills <bcmills@google.com> | 2021-05-13 09:48:40 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2021-05-15 02:39:08 +0000 |
commit | ce92a2023ccd77ca609126aa8a6e881c9def57f0 (patch) | |
tree | 32f11fab97c8c79747f3a26d6fc9a938bc247422 /src/cmd/go/internal/modload/load.go | |
parent | 02699f810a05215060ba2181f394d551819ad7d4 (diff) | |
download | go-ce92a2023ccd77ca609126aa8a6e881c9def57f0.tar.gz go-ce92a2023ccd77ca609126aa8a6e881c9def57f0.zip |
cmd/go: error out of 'go mod tidy' if the go version is newer than supported
Fixes #46142
Change-Id: Ib7a0a159e53cbe476be6aa9a050add10cc750dec
Reviewed-on: https://go-review.googlesource.com/c/go/+/319669
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r-- | src/cmd/go/internal/modload/load.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index f30ac6e0c8b..83fc7c09c37 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -922,7 +922,8 @@ func loadFromRoots(ctx context.Context, params loaderParams) *loader { } if params.GoVersion != "" { - if semver.Compare("v"+params.GoVersion, narrowAllVersionV) < 0 && !ld.UseVendorAll { + goVersionV := "v" + params.GoVersion + if semver.Compare(goVersionV, narrowAllVersionV) < 0 && !ld.UseVendorAll { // The module's go version explicitly predates the change in "all" for lazy // loading, so continue to use the older interpretation. // (If params.GoVersion is empty, we are probably not in any module at all @@ -930,6 +931,11 @@ func loadFromRoots(ctx context.Context, params loaderParams) *loader { ld.allClosesOverTests = true } + if ld.Tidy && semver.Compare(goVersionV, "v"+latestGoVersion()) > 0 { + ld.errorf("go mod tidy: go.mod file indicates go %s, but maximum supported version is %s\n", params.GoVersion, latestGoVersion()) + base.ExitIfErrors() + } + var err error ld.requirements, err = convertDepth(ctx, ld.requirements, modDepthFromGoVersion(params.GoVersion)) if err != nil { |