-
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
x/tools/gopls: improve cgo support #32898
Comments
Just to confirm, any file that imports
For example, an attempt to go-to-def on
At least based on some rough tests, I can't get anything to work when a file imports |
Actually, this appears to be limited to files that |
Here is a test that demonstrates the issue within This attempts to go-to-def from
|
I think I've found the cause of this.
These cache files appear to be the cgo source. Because the name doesn't match the file name of the original source, gopls is unable to attribute the metadata. I'm not sure what the 'right' solution is, but i found a quick hack that enumerates GoFiles and CgoFiles instead of using CompiledGoFiles: (
|
The generated files that correspond to real files have a |
load.go got changed in master, here's an updated diff for the hacky fix...
|
Change https://golang.org/cl/202238 mentions this issue: |
@stamblerre I've gone back and done a more detailed analysis for the change in https://golang.org/cl/202238. I've come to the same conclusion that the 'ids' map in snapshot should be populated from pkg.GoFiles. It might be that i should raise a separate issue for the change, as it doesn't really add 'cgo support' - what it does do is fix the breakage of gopls on Go symbols in packages where there is a cgo file. Analysis is here: https://docs.google.com/document/d/1r5iVQdcAhMhGKDi0rc-sgBF4ZAsrZuZvRs9Zz2Y_6vQ/edit?usp=sharing There are two different types of generation as far as I could model it. For I wasn't able to locate anywhere in the gopls code where the clients of the snapshot.ids map are currently expecting it to be populated with the CompiledGoFiles list. I'm hoping you'll reconsider the change, and guide me if it would be better to raise a separate issue for the improvement the change makes. |
It's a shame that gopls gets jammed by cgo being involved, because this hampers the value of the wonderfully clean OpenGL wrapper packages provided by the go-gl organisation. |
Original issue: #31561.
Currently,
gopls
does not crash withcgo
, but language features are still missing for any symbols imported from"C"
.The text was updated successfully, but these errors were encountered: