-
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: add tests for cgo #31561
Comments
Using It test work well. |
I can confirm that this happens with vscode-go as well. Given a file with any sort of cgo header:
gopls always returns "no file information" error:
And, of course, no code editing assist features are working in such files. Other files in the very same package/project work just fine. |
@stamblerre is there a downside to the workaround that @wwcd suggests above? |
Sorry for my delayed response on this issue. We are still trying to figure out the right way to handle cgo. Unfortunately, @wwcd's suggestion won't work for us. We have to use We probably won't have a meaningful solution for autocompletion and other language features in cgo files, but as a start @ianthehat and I have discussed simply disabling diagnostics for all generated files. |
@stamblerre In this case, would I still get autocompletion of Go stuff just not C stuff in a file with C and Go? If so, I would be OK with that. |
@stamblerre Just curious on an answer to the above question. |
the https://github.com/cri-o/cri-o.git use cgo, Causes Gopls not to work, no prompts |
Change https://golang.org/cl/181546 mentions this issue: |
This change should fix the TryBot failures exposed by https://golang.org/cl/181317. Updates golang/go#31561 Change-Id: Ie77c9e3bfd6825dcd2608523e72f804f81d3f48c Reviewed-on: https://go-review.googlesource.com/c/tools/+/181546 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Cottrell <[email protected]>
I have the same issue with gopls and cgo using coc.nvim.
|
Things look to be working much more better now and I am not seeing gopls crashes when it cannot find references generated from cgo, this issue can be closed. |
I seem to still be having the same problems. Was there an update that should have fixed this issue? |
Re-opening this issue because we still need to do a better job supporting @joegrasse: |
@stamblerre Would |
@joegrasse: What errors do you see? Edit: Remove |
Here is the error I am getting.
|
Are you able to get the version with the |
Same error. Looks like the version of git on CentOS 6 doesn't support the |
Ok, sounds like this is an issue with the Closing this issue. Filed #32898 for |
Back to the cgo issue, I believe I have the most up-to-date version of To clarify, within the same project, I can get autocomplete information for a source file that is pure Go, but not on a file that does |
Can you confirm your version with |
Here is the output from |
Are you able to share |
Yes, I can share logs, but I am using vim. |
For other editors, you will need to pass in |
Here is what I could get.
They are both in the same package. |
It seems like |
I have the exact same problem in my project using |
Here is the output you requested. go list -e -json -compiled -test /usr2/ps/baseline.mount/isp.src/gosrc/private.url.com/ext/daemon-example/{ "Dir": "/usr2/ps/isp/go/src/private.url.com/ext/daemon-example", "ImportPath": "private.url.com/ext/daemon-example", "Name": "main", "Doc": "Command daemon-example is a basic example of a Go program interfacing with the PIM C code.", "Target": "/usr2/ps/isp/go/bin/daemon-example", "Root": "/usr2/ps/isp/go", "Match": [ "/usr2/ps/baseline.mount/isp.src/gosrc/private.url.com/ext/daemon-example" ], "GoFiles": [ "signals.go" ], "CgoFiles": [ "build_dev_386.go", "daemon-example.go" ], "CompiledGoFiles": [ "signals.go", "/usr2/shared/graj04/.cache/go-build/12/12a0df01d2653f3fdf63b149a9ab198d22bcc6bc35091bd1e59818918016703a-d", "/usr2/shared/graj04/.cache/go-build/92/923c6c623035425c055bacd76564b9668260819645ecda973baf6e31b43a15da-d", "/usr2/shared/graj04/.cache/go-build/60/606a12f8b205cde299956cb497b55d1ad282e99adb31eac014a738206463f65e-d", "/usr2/shared/graj04/.cache/go-build/34/3414d2cd2f62ddebbc12451972710640fc0a183272686838bc1a242649260ce0-d" ], "IgnoredGoFiles": [ "build_dev_amd64.go", "build_prod_386.go", "build_prod_amd64.go" ], "CgoCFLAGS": [ "-I/usr2/ps/isp/include/sys", "-I/usr2/ps/isp/src/sys", "-I/usr2/ps/3rdParty/libunwind/libunwind-current_i686/include" ], "CgoLDFLAGS": [ "-L/usr2/ps/isp/lib", "-lps", "-L/usr2/ps/3rdParty/libunwind/libunwind-current_i686/lib", "-l:libunwind.a" ], "Imports": [ "C", "flag", "fmt", "private.url.com/lib/platform/genlog", "os", "os/signal", "runtime", "runtime/debug", "sync", "syscall", "time", "unsafe", "runtime/cgo" ], "Deps": [ "bytes", "errors", "flag", "fmt", "private.url.com/lib/platform/genlog", "internal/bytealg", "internal/cpu", "internal/fmtsort", "internal/poll", "internal/race", "internal/syscall/unix", "internal/testlog", "io", "math", "math/bits", "os", "os/signal", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/cgo", "runtime/debug", "runtime/internal/atomic", "runtime/internal/math", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "time", "unicode", "unicode/utf8", "unsafe" ] } |
Also just as @suizman, if I comment out |
Thanks for the reports. Re-opening this issue so that I add some tests for |
Hi, Have the same problem, here are the logs: Log gopls
go list -e -json -compiled -test
Hope this can help, let me know if you need anything else. Thanks! |
Duplicate of #32898 |
@stamblerre I don't believe this is a duplicate of #32898. At least not the way it is described in that issue. In #32898 gopls doesn't work with symbols imported from "C". The problem I (and I believe others) have had and described in this issue is that symbols imported from say "fmt" don't work in files that also import "C". |
@joegrasse: In general, |
also note that files that import "C" are not true go files, they are cgo files that have to be translated before they become go files, which means they are not in the set of files presented to the go compiler (which are the same set of files that we can typecheck correctly). |
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
)?go env
OutputWhat did you do?
See minimal working example in the following repository
https://github.com/Kraust/cgo_gopls
Tested with latest coc.nvim and latest gopls from official repo.
Not listed in the repository is my coc.nvim settings. I do not believe this is a coc.nvim issue but I will post an issue on their tracker if needed:
What did you expect to see?
coc.nvim with successful tab-compeltion (autocomplete)
What did you see instead?
coc.nvim's tab completion only works if
import "C"
is commented out.Also CocInfo reports the following:
The text was updated successfully, but these errors were encountered: