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: wrong output for a non-canonical import path #16954
Comments
/cc @josharian @randall77 |
I've also run in to this issue
|
The issue was an import with a trailing To find the problem in the terminal you can use |
I suspect this is an issue with go/build or cmd/go. @rsc ? |
The compiler error is accurate, but it's confusing because it was caused by cmd/go propagating a problem from higher in the import tree to a lower level. cmd/go should diagnose the problem earlier. |
CL https://golang.org/cl/31668 mentions this issue. |
When importing a package with a non-canonical import path (ending in a slash), the compiler error tells you about it and points you to the offending import.
If the imported package imports a vendored package (and only then), the compiler error points to the wrong location and the error text is wrong too. See below in the expected/actual output.
What version of Go are you using (
go version
)?go version go1.7 linux/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
go build ./...
in a project with those three files inside:main.go:
lib/lib.go:
vendor/vendoredlib/vendoredlib.go:
What did you expect to see?
Compiler error like this:
What did you see instead?
Note that the error points to an import in lib.go, where everything is correct, instead of to main.go. Also the error text talks about
github.com/benma/test//vendor/vendoredlib
vsgithub.com/benma/test/vendor/vendoredlib
, where the actual import in lib.go:3 is simplyimport "vendoredlib"
.On a related note, shouldn't
goimports
fix wrong imports like that (and simply strip the trailing slash)?The text was updated successfully, but these errors were encountered: