mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
16b5d766d8
commit
e552a6d312
2 changed files with 11 additions and 4 deletions
|
|
@ -178,11 +178,13 @@ func (e *ImportMissingSumError) Error() string {
|
||||||
// Importing package is unknown, or the missing package was named on the
|
// Importing package is unknown, or the missing package was named on the
|
||||||
// command line. Recommend 'go mod download' for the modules that could
|
// command line. Recommend 'go mod download' for the modules that could
|
||||||
// provide the package, since that shouldn't change go.mod.
|
// provide the package, since that shouldn't change go.mod.
|
||||||
|
if len(e.mods) > 0 {
|
||||||
args := make([]string, len(e.mods))
|
args := make([]string, len(e.mods))
|
||||||
for i, mod := range e.mods {
|
for i, mod := range e.mods {
|
||||||
args[i] = mod.Path
|
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 {
|
} else {
|
||||||
// Importing package is known (common case). Recommend 'go get' on the
|
// Importing package is known (common case). Recommend 'go get' on the
|
||||||
// current version of the importing package.
|
// current version of the importing package.
|
||||||
|
|
|
||||||
5
src/cmd/go/testdata/script/mod_install_hint.txt
vendored
Normal file
5
src/cmd/go/testdata/script/mod_install_hint.txt
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Module is replaced but not required. No hint appears as no module is suggested.
|
||||||
|
go mod init m
|
||||||
|
go mod edit -replace=github.com/notrequired@v0.5.0=github.com/doesnotexist@v0.5.0
|
||||||
|
! go install github.com/notrequired
|
||||||
|
! stderr 'to add it:'
|
||||||
Loading…
Add table
Add a link
Reference in a new issue