-
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/go: go list -e should list a package containing an error if files named on the command line do not exist #29280
Comments
Change https://golang.org/cl/154517 mentions this issue: |
The underlying problem is that go list -e doesn't exit 0 (as it should) when an ad-hoc package doesn't exist. I've sent a cl to suppress the error in go packages, and then I'll re-purpose this bug to target that issue. |
Updates golang/go#29280 Change-Id: Ie5a5dc1fef8f3d989b3a5fffb6c2ca66e97c143a Reviewed-on: https://go-review.googlesource.com/c/154517 Reviewed-by: Ian Cottrell <[email protected]>
Thanks for the quick reply. It sounds to me like most tools out there want to check for most or all errors, and the fact that Perhaps this should be clearer in the docs, e.g. via an example that most static analysis tools should follow. Edit: I just realised that the package example does include |
Here's another bug - missing files in syntax mode produce no command-line-arguments package at all, which seems like a bug to me too:
This is on x/tools 13ba8ad and |
I had forgotten to check those. Otherwise, we might be ignoring parse or typecheck errors. We can't fix the TODO in load_test.go yet, because it looks like there's another bug in go/packages. See golang/go#29280.
It should be noted that this issue is (no longer?) limited to LoadSyntax. It occurs in all modes.
|
@dominikh I think the 0 exit status is working as intended. In these cases, go/packages should return a package with a non-empty Errors field. Is it not doing that? |
@matloob for me, it returns zero packages and no error. |
@matloob I think you forgot to repurpose this issue? |
Change https://golang.org/cl/171018 mentions this issue: |
…c package If a file in an ad-hoc package doesn't exist, go list should exit 0 and return an dummy package with an error set on it. Since it doesn't do that yet, add a work-around. Updates golang/go#29280 Change-Id: I6019f28ce4770582f274919d1aa35d85a634687e Reviewed-on: https://go-review.googlesource.com/c/tools/+/171018 Run-TryBot: Michael Matloob <[email protected]> Reviewed-by: Ian Cottrell <[email protected]>
@matloob, could you clarify the issue with |
An ad-hoc package is the term used throughout the tools for one formed when you pass the go command a list of files. |
Change https://golang.org/cl/185345 mentions this issue: |
@mvdan, this appears to be fixed at head. Can you confirm?
CC @jayconrod |
Yes, I no longer see this bug - I checked both module mode and GOPATH mode. There were a number of CLs above, so it's hard to see exactly when this happened. I assume |
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]>
Seems to me like the
LoadSyntax
mode should error too. Found while porting https://github.com/mvdan/gogrep fromgo/loader
togo/packages
, since some error test cases stopped erroring as expected./cc @ianthehat @matloob
The text was updated successfully, but these errors were encountered: