-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: poor error message when resolving an import path that is missing from the main module #38224
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
Comments
When I try this in GOPATH mode, I get:
|
The mechanism here is working as intended, but the diagnostic message should be better. If you have modules It's best to avoid interleaving modules like this, but the situation can come up when splitting a large module into smaller pieces, so it's important that the mechanism keeps working. That said, when the |
In my particular case, the module I'm working on is not currently accessible, so the fetch fails. Because my IDE (VSCode) uses gopls to update imports on save, this considerably delays saves. When I build, I get:
|
Here's the behavior I see, with a current 1.15 development version of
|
That second error message is closer, but still not right: we should probably be returning a go/src/cmd/go/internal/modload/query.go Lines 636 to 641 in 339e9c6
But for some reason we're explicitly overriding that error message with what seems to be a much worse one: go/src/cmd/go/internal/modload/import.go Lines 284 to 285 in 339e9c6
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, as of 1.14
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Given a
module example.com/repo
defined in./go.mod
, if directory./a
does not contain any Go files and a package./a/b
containsimport "example.com/repo/a"
,go build ./a/b
will attempt to fetchexample.com/repo/a
even though./a
is clearly within a module.Reproduced here: https://github.com/firelizzard18/golang-issue-38224
What did you expect to see?
What did you see instead?
go build -c -v ./a/b
OutputThe text was updated successfully, but these errors were encountered: