-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: 'go vet' cannot resolve imports of vendored packages #17571
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
The problem is simple at root: vet can't find the imports, and without the imports it cannot type-check. You need to figure out why on your machine those imports are not available, or at least appear not to be available to vet. Perhaps you have multiple go installations, or different GOPATHs set, or have simply not installed those dependencies. But this is not a vet bug. |
The problem seems to be somewhere in your Makefile, it is not a tool bug.
|
No
Well, we do overwrite the original Please try it yourself — do not use |
go tool vet -v
throwing errors for no apparent reason
Looks like an inconsistency bug. I can reproduce with your specific example but it also does much work such as maintaining a copy of the GOPATH under vendor directory. A smaller reproducible would be nice to have. |
$ git clone https://github.com/leonklingele/go-tool-vet-v-issues
$ cd go-tool-vet-v-issues
$ make
$ make govet Fails with:
$ bin/hello # Works fine |
The problem here is that vet is trying to process an import of a vendored package, but it has not been given the mapping from import paths to expanded vendor paths like the compiler has available. That map probably needs to be passed from cmd/go to vet much as it is for compile. And then vet has to pass it to go/internal/gcimporter. Would like to fix this but it's been broken since Go 1.6, so I think it can wait another release. Note that 'go tool vet' is never going to get this right. You want to be using 'go vet' instead. We should probably make 'go vet -v' pass the -v through to the vet invocation though. |
Vet will need even more work along these lines with the new caching work planned for Go 1.10. But then things will be better, and this will be fixed. |
I have the similar issue on go 1.9, command |
Change https://golang.org/cl/74750 mentions this issue: |
Follow-up of https://groups.google.com/forum/#!topic/golang-nuts/W8lvnNlcO2o
What version of Go are you using (
go version
)?1.7.3
What operating system and processor architecture are you using (
go env
)?darwin/amd64, linux/amd64
Steps to reproduce
Output
There are two main issues:
could not import / can't find import
commands/version.go:15: can't check non-constant format in call to Printf
Is this a bug in
go tool vet
? How to fix these "issues"?The text was updated successfully, but these errors were encountered: