Description
A Go module path is not necessarily a valid Go package path: for example, golang.org/x/tools
is a valid module path, but since there are no .go
files in the repo root it is not an importable package.
go get
in GOPATH
mode returns a non-zero exit code if that happens, but today in module mode we explicitly suppress that error:
go/src/cmd/go/internal/modget/get.go
Lines 532 to 536 in dbd323b
On the other hand, if the user intends to pass a module path (rather than a package path), they can indicate that explicitly using the -m
flag.
Should we change the error-suppressing path to instead produce a non-zero exit code? We could still make the error explicit about the fact that the requested path is a module but not a package.
(CC @rsc @hyangah @myitcv @thepudds @jayconrod )