if err != nil {
// TODO: It would be nice to return an error like "not a module".
// Right now we return "missing go.mod", which is a little confusing.
- return nil, err
+ return nil, &module.ModuleError{
+ Path: r.modPath,
+ Err: &module.InvalidVersionError{
+ Version: info2.Version,
+ Err: notExistError(err.Error()),
+ },
+ }
}
}
{
vcs: "git",
path: "github.com/rsc/vgotest1/subdir",
- err: "missing github.com/rsc/vgotest1/subdir/go.mod at revision a08abb797a67",
+ err: "github.com/rsc/vgotest1/subdir@v0.0.0-20180219223237-a08abb797a67: invalid version: missing github.com/rsc/vgotest1/subdir/go.mod at revision a08abb797a67",
},
{
vcs: "mod",
go mod edit -require golang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c
cd outside
! go list -m golang.org/x/text
-stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c: missing golang.org/x/text/unicode/go.mod at revision 14c0d48ead0c'
+stderr 'go: example.com@v0.0.0 requires\n\tgolang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c: invalid version: missing golang.org/x/text/unicode/go.mod at revision 14c0d48ead0c'
cd ..
! go list -m golang.org/x/text
-stderr 'golang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c: missing golang.org/x/text/unicode/go.mod at revision 14c0d48ead0c'
+stderr 'golang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c: invalid version: missing golang.org/x/text/unicode/go.mod at revision 14c0d48ead0c'
+
+# However, arguments to 'go get' can name packages above the root.
+cp go.mod.orig go.mod
+go get -d golang.org/x/text/unicode@v0.0.0-20170915032832-14c0d48ead0c
+go list -m golang.org/x/text/...
+stdout 'golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c'
+! stdout 'golang.org/x/text/unicode'
# A major version that does not match the module path is invalid.
cp go.mod.orig go.mod