-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/tools/gopls: show error messages about "orphaned" files to the user #31668
Comments
Thanks for this ticket Go team! 🙏 |
Change https://golang.org/cl/194018 mentions this issue: |
If we encounter `go list` errors when loading a user's package, we should try to see if they've encountered any of our common error cases. They are: 1) a user has GO111MODULE=off, but is outside of their GOPATH, and 2) a user is in module mode but doesn't have a go.mod file. Fortunately, go/packages does a great job handling edge cases so gopls will work well for most of them. The main issue will be unresolved imports. These show up in DepErrors in `go list`, so go/packages doesn't propagate them through to the list of errors. This will require changes to go/packages. Updates golang/go#31668 Change-Id: Ibd5253b33b38caffeaad54a403c74c0b861fcc14 Reviewed-on: https://go-review.googlesource.com/c/tools/+/194018 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Cottrell <[email protected]>
If we encounter `go list` errors when loading a user's package, we should try to see if they've encountered any of our common error cases. They are: 1) a user has GO111MODULE=off, but is outside of their GOPATH, and 2) a user is in module mode but doesn't have a go.mod file. Fortunately, go/packages does a great job handling edge cases so gopls will work well for most of them. The main issue will be unresolved imports. These show up in DepErrors in `go list`, so go/packages doesn't propagate them through to the list of errors. This will require changes to go/packages. Updates golang/go#31668 Change-Id: Ibd5253b33b38caffeaad54a403c74c0b861fcc14 Reviewed-on: https://go-review.googlesource.com/c/tools/+/194018 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Cottrell <[email protected]>
I believe that the main remaining case to address here is files excluded by build tags. We should probably show a pop-up saying that we can't map them to any package. (Maybe we should do that for all files we can't place in a package?) |
Change https://golang.org/cl/253798 mentions this issue: |
Build tags are a common stumbling block for users of gopls, as build tagged files may be excluded from the initial workspace load without a clear warning. This change adds a check for every opened file to confirm if it maps to a package. If not, we show a message with suggestions. A follow-up improvement might be to check if the opened file actually has build tags to make the error message more precise (and give a better example config). Updates golang/go#31668 Change-Id: I829d8546edea65aa08274021bfde8ea2fb6eeaa1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/253798 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Findley <[email protected]>
A few more ideas for how to improve this:
|
Change https://golang.org/cl/256977 mentions this issue: |
There are a few ways we have problems working on a file, and we need to report them to the user in a way that lets them understand and fix the problem
Some causes are:
Each of these may require a different mechanism for detection, a different heuristic to suggest the root cause or fix, and maybe a different way to report the error.
The text was updated successfully, but these errors were encountered: