diff options
author | Constantin Konstantinidis <constantinkonstantinidis@gmail.com> | 2021-06-05 07:48:30 +0200 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2021-06-11 21:43:54 +0000 |
commit | e552a6d31270c86064632af1d092e0db5a930250 (patch) | |
tree | 448ee9e15661b899d64ac85c081c6b7aedf0eef3 /src/cmd/go/internal/modload/import.go | |
parent | 16b5d766d8af8bc348f93e6cb2b53a4e2d5d72ca (diff) | |
download | go-e552a6d31270c86064632af1d092e0db5a930250.tar.gz go-e552a6d31270c86064632af1d092e0db5a930250.zip |
cmd/go: remove hint when no module is suggested
Fixes #46528
Change-Id: I2453d321ece878ea7823865758aa4a16b3ed7fe8
Reviewed-on: https://go-review.googlesource.com/c/go/+/325430
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Trust: Heschi Kreinick <heschi@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/import.go')
-rw-r--r-- | src/cmd/go/internal/modload/import.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go index f76befcfe3..60bd26fb22 100644 --- a/src/cmd/go/internal/modload/import.go +++ b/src/cmd/go/internal/modload/import.go @@ -178,11 +178,13 @@ func (e *ImportMissingSumError) Error() string { // Importing package is unknown, or the missing package was named on the // command line. Recommend 'go mod download' for the modules that could // provide the package, since that shouldn't change go.mod. - args := make([]string, len(e.mods)) - for i, mod := range e.mods { - args[i] = mod.Path + if len(e.mods) > 0 { + args := make([]string, len(e.mods)) + for i, mod := range e.mods { + args[i] = mod.Path + } + hint = fmt.Sprintf("; to add:\n\tgo mod download %s", strings.Join(args, " ")) } - hint = fmt.Sprintf("; to add:\n\tgo mod download %s", strings.Join(args, " ")) } else { // Importing package is known (common case). Recommend 'go get' on the // current version of the importing package. |