Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: "go get" can fail in a confusing way on the module path #44962

Open
mvdan opened this issue Mar 12, 2021 · 2 comments
Open

cmd/go: "go get" can fail in a confusing way on the module path #44962

mvdan opened this issue Mar 12, 2021 · 2 comments

Comments

@mvdan
Copy link
Member

@mvdan mvdan commented Mar 12, 2021

I found this weird error while writing a reproducer for #44961. Using x/tools as an example:

$ go version
go version devel +cf59850466 Wed Mar 10 09:01:05 2021 +0000 linux/amd64
$ cd src/tools
$ git checkout -q 44abc2a71b321b77c0a579d8c5bf2704d648c9e0
$ go get -d golang.org/x/tools
go get golang.org/x/tools: unrecognized import path "golang.org/x": parse https://golang.org/x?go-get=1: no go-import meta tags ()
$ go get -d golang.org/x/tools@latest
go get: can't request version "latest" of the main module (golang.org/x/tools)
$ go get -d golang.org/x/tools@master
go get: can't request version "master" of the main module (golang.org/x/tools)

I'm not sure why the first go get gives that weird error message. I would expect the three commands to error in the same way.

@jayconrod jayconrod added the NeedsFix label Mar 12, 2021
@jayconrod jayconrod added this to the Go1.17 milestone Mar 12, 2021
@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Mar 12, 2021

I think the can't request version "latest" of the main module messages are correct.

unrecognized import path "golang.org/x" is weird and confusing. I'm guessing that only comes up if the argument is the main module path? The go command would disqualify that when searching for packages, so it would be as if you typed go get golang.org/x, in which case that would be the correct message.

We should probably treat go get golang.org/x/tools just like go get golang.org/x/tools@upgrade. Technically, you might be looking for a package with the same path as the main module that actually is provided by another module, but it's unlikely.

@mvdan
Copy link
Member Author

@mvdan mvdan commented Mar 12, 2021

Technically, you might be looking for a package with the same path as the main module that actually is provided by another module, but it's unlikely.

I think that falls under "noone should ever ever do this", so I don't think the error message should mention a parent module. I don't think we should even try to look for a parent module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants