// 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.
--- /dev/null
+# Module is replaced but not required. No hint appears as no module is suggested.\r
+go mod init m\r
+go mod edit -replace=github.com/notrequired@v0.5.0=github.com/doesnotexist@v0.5.0\r
+! go install github.com/notrequired\r
+! stderr 'to add it:'
\ No newline at end of file