-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: line numbers don't show up for "internal package not allowed" errors from _test files #36173
Comments
Hi @YUANLAI. I've attempted to reproduce the scenario posted above. |
I using emacs flycheck wrap the go-vet, the error occurs seems happen between flycheck and go-vet. flycheck/flycheck#1659 (comment) |
If the error comes from flycheck and not go-vet, then I'm afraid there is nothing we can do here. But the issue you linked to shows that the issue is with vet. Could you please clarify ? Please post the exact instructions that we can run from the command line to reproduce this. Thank you. |
I think there are two bugs here (one in flycheck and one in the The For example:
Notice that the first invocation reports line numbers, and the second invocation does not. This confuses How hard is it to fix this error message to have the right line numbers? |
To be clear, Flycheck is failing because go-vet is producing error messages that don't match the usual pattern (which includes a line number). Fixing that is just a matter of making that message conform to the usual template. Now, the reason users are running into this message is that we create a temporary copy of their file (including unsaved changes) in a temporary directory before running go-vet; this breaks imports. The ideal solution for us would be a way to feed file contents to go vet on stdin; then we wouldn't have to create temporary files: we'd just pass unsaved file contents on stdin and tell go-vet what the original file name was, so it could look up the imports properly. (this is what we're doing with most other checkers). |
Thanks for the clarification ! I have a few follow-up questions:
|
My pleasure! I'll let go users answer the two questions, since I don't know the answers myself :) |
Yes, this is a regression. The bug is in Go 1.13, but not in Go 1.12 Repro steps: Create a Dockerfile like
Run
Result:
Note that if I change the go version to 1.12 in the Dockerfile I get:
which has the correct error message |
I did a git bisect and confirmed the bug was introduced by this commit: f1d5ce0 The commit before that one does not have the bug |
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Change https://golang.org/cl/217106 mentions this issue: |
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
Change https://golang.org/cl/185345 mentions this issue: |
Change https://golang.org/cl/220718 mentions this issue: |
This change is a non-minimal fix for #32917, but incidentally fixes several other bugs and makes the error messages much more ergonomic. Updates #32917 Updates #27122 Updates #28459 Updates #29280 Updates #30590 Updates #37214 Updates #36173 Updates #36587 Fixes #36008 Fixes #30992 Change-Id: Iedb26d2e0963697c130df5d0f72e7f83ec2dcf06 Reviewed-on: https://go-review.googlesource.com/c/go/+/185345 Reviewed-by: Michael Matloob <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
Change https://golang.org/cl/224660 mentions this issue: |
Change https://golang.org/cl/225677 mentions this issue: |
…versions Go 1.15+, as of CL 224660, puts the importing package on the top of the stack (because it makes more sense in the errors). Look there by default and fall back to second from top position if top of stack is the package itself. Updates golang/go#36173 Change-Id: I1681089b4a18af9e535661668329ad32b1ba1936 Reviewed-on: https://go-review.googlesource.com/c/tools/+/225677 Run-TryBot: Michael Matloob <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?darwin/amd64
go env
OutputWhat did you do?
The text was updated successfully, but these errors were encountered: