From a19c925eda6987d91f316639db2ce774725f7a1a Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Fri, 20 Nov 2020 11:18:15 -0500 Subject: [PATCH] cmd/go: recommend 'go get' command to switch from retracted versions This CL restores a message unintentionally removed in CL 270858. For #24031 Change-Id: I957c5c59e624df98e72dfff351298bfc5bf9a9e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/272066 Trust: Jay Conrod Run-TryBot: Jay Conrod Reviewed-by: Bryan C. Mills TryBot-Result: Go Bot --- src/cmd/go/internal/modget/get.go | 9 +++++++++ src/cmd/go/testdata/script/mod_get_retract.txt | 1 + 2 files changed, 10 insertions(+) diff --git a/src/cmd/go/internal/modget/get.go b/src/cmd/go/internal/modget/get.go index 2413fd20bcf..ecb01425243 100644 --- a/src/cmd/go/internal/modget/get.go +++ b/src/cmd/go/internal/modget/get.go @@ -1567,11 +1567,20 @@ func (r *resolver) checkPackagesAndRetractions(ctx context.Context, pkgPatterns }) } <-r.work.Idle() + var retractPath string for _, r := range retractions { if r.err != nil { fmt.Fprintf(os.Stderr, "go: warning: %v\n", r.err) + if retractPath == "" { + retractPath = r.m.Path + } else { + retractPath = "" + } } } + if retractPath != "" { + fmt.Fprintf(os.Stderr, "go: run 'go get %s@latest' to switch to the latest unretracted version\n", retractPath) + } } // reportChanges logs version changes to os.Stderr. diff --git a/src/cmd/go/testdata/script/mod_get_retract.txt b/src/cmd/go/testdata/script/mod_get_retract.txt index 13a47bc359d..6e328eb5929 100644 --- a/src/cmd/go/testdata/script/mod_get_retract.txt +++ b/src/cmd/go/testdata/script/mod_get_retract.txt @@ -11,6 +11,7 @@ cp go.mod.orig go.mod go mod edit -require example.com/retract/self/prev@v1.9.0 go get -d example.com/retract/self/prev stderr '^go: warning: example.com/retract/self/prev@v1.9.0: retracted by module author: self$' +stderr '^go: run ''go get example.com/retract/self/prev@latest'' to switch to the latest unretracted version$' go list -m example.com/retract/self/prev stdout '^example.com/retract/self/prev v1.9.0$'