-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/vet: more clearly document go tool vet on a single file #23916
Comments
To run |
Will |
It's true that some checks are only available if type checking information is available. That's not a change from 1.9, though. Offhand I'm not sure which vet tests are affected. |
I confirmed the behavior differs between
|
So I guess the breaking change already happened, and there is a workaround ( Can we commit to saying |
See golang/go#23916 for bug details.
I understand that this change of behavior of |
The fact that |
Considering this, wouldn't it make sense for |
From
Both accept files. The question is whether it's a requirement that they form a complete package or not. |
As of 1.10, `go vet` no longer works correctly on individual files. As such, we use `go tool vet` instead. See golang/go#23916 for more information.
It's not clear to me what to do here. I feel like there is documentation for how the tool works at https://golang.org/cmd/vet. It's true that vet changed from 1.9 to 1.10, and that was documented in the release notes. The question now is: what, if anything, needs to change in the cmd/vet and/or cmd/go docs? It would be very helpful if people who think that there should be a change could send in a CL. Thanks. |
No response, so I'm going to close this issue. Please comment if you disagree. |
Rather than running go vet on a single file at a time, we are required to run it on the entire project. This is because `go tool vet` and `go vet` differ in behavior. `go tool vet` is able to analyze and infer types in a single file. `go vet` is unable to do so (and requires the context of the entire project`. We change the behavior to run `go vet` on the entire project. More captured in this issue: golang/go#23916
Ensure we vet the entirety of the project Rather than running go vet on a single file at a time, we are required to run it on the entire project. This is because `go tool vet` and `go vet` differ in behavior. `go tool vet` is able to analyze and infer types in a single file. `go vet` is unable to do so (and requires the context of the entire project`. We change the behavior to run `go vet` on the entire project. More captured in this issue: golang/go#23916
What did you do?
After upgrading from 1.9.4 to 1.10, I ran
go vet
against a single test file.I have simplified the code that gave me the original issue and uploaded it
here.
What did you expect to see?
No output, and a successful exit code. This command succeeded on Go 1.9.4.
What did you see instead?
What's happening here is that
go vet
is complaining about not being able tofind the definition of an identifier that was declared in a different file in
the same package.
It looks like this change in behaviour was introduced in an effort to run
go vet
in parallel withgo test
, specifically in https://golang.org/cl/74355which causes
go vet
to fail when the type check fails.I'm not really sure what the best course of action is here. My thought is that
when running go vet against a single file, you can never be guaranteed to have
all of the type information you need, so we could ignore type check failures in
vet against single files.
System details
The text was updated successfully, but these errors were encountered: