return m, "", &ImportMissingError{Path: path, Module: m}
}
}
+ if len(mods) > 0 && module.CheckPath(path) != nil {
+ // The package path is not valid to fetch remotely,
+ // so it can only exist if in a replaced module,
+ // and we know from the above loop that it is not.
+ return module.Version{}, "", &PackageNotInModuleError{
+ Mod: mods[0],
+ Query: "latest",
+ Pattern: path,
+ Replacement: Replacement(mods[0]),
+ }
+ }
}
candidates, err := QueryPackage(path, "latest", Allowed)
stdout 'example.com/x/v3 v3.0.0-00010101000000-000000000000 => ./v3'
stdout 'example.com/v v1.12.0 => ./v12'
+# The go command should print an informative error when the matched
+# module does not contain a package.
+cd fail
+! go list all
+stdout 'localhost.fail'
+stderr '^can.t load package: m.go:3:8: module w@latest found \(v0.0.0-00010101000000-000000000000, replaced by ../w\), but does not contain package w$'
+
-- go.mod --
module example.com/m
module v.localhost
-- v/v.go --
package v
+
+-- fail/m.go --
+package main
+
+import _ "w"
+
+func main() {}
+
+-- fail/go.mod --
+module localhost.fail
+
+replace w => ../w
+