-
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: bazel gopackages driver reports C source files among Go files, leading to parse errors #56208
Comments
Thanks for providing the repro. We will take a look. |
any updates? This is not a blocking issue but affects productivity. |
Hi, I also am experiencing the same problem, just with another repo (gocv : https://github.com/hybridgroup/gocv) which uses cgo and has cpp code in it:
The code builds and runs fine just as the original issue mentions. |
Thanks for following up. We haven't yet investigated. Just to confirm, you are both using bazel, right? You have set GOPACKAGESDRIVER? |
Yes to using bazel and I have the following configured in vscode settings:
With the contents of that specified
|
I am using Bazel. The setting is same as michaelarusso:
The content has one more line:
|
We don't really support bazel (see https://github.com/golang/tools/tree/master/gopls#supported-go-versions-and-build-systems), but would gladly accept contributions (or fix minor bugs ourselves) if there is low-hanging fruit. Based on the nature of the error, I suspect that this may be low-hanging fruit and may even be a logical bug in our code, independent of bazel, It would take me some time to get set up with bazel. If you want to help debug, I would be curious to see the following:
|
Could you run this command:
and see how it mentions it |
I tried to use the instructions for
|
Thanks. It seems pretty clear that the Bazel gopackages driver is including non-Go files among the lists of Go files. I'm not familiar with that program; I suggest you file an issue at https://github.com/bazelbuild/rules_go. |
Thanks. Opened bazel-contrib/rules_go#3326 |
Thanks. I'll close this issue now. |
gopls version
v0.9.5
go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="<...>/wzihao/go/bin"
GOCACHE="<...>/wzihao/.cache/go-build"
GOENV="<...>/wzihao/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-mod=mod"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="<...>/wzihao/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="<...>/wzihao/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="<...>/external/go_sdk"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="<...>/external/go_sdk/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="<...>/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4086805148=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I am using VSCode + Go extension for my project.
In my project I imported "github.com/mattn/go-sqlite3". There are errors related to that.
By default CGO_ENABLED=1, I tried to change it to 0, reload VScode window, but still does not work.
What did you expect to see?
No errors importing "github.com/mattn/go-sqlite3" and the
go to
features works with itWhat did you see instead?
Errorrs when importing and indexing. See logs below.
Editor and settings
No custom settings regarding gopls.
Logs
When hanging on the package, the error message is:
could not import github.com/mattn/go-sqlite3 (cannot parse non-Go file file:///<usr>/.cache/bazel/_bazel_<usr>/<...>/external/com_github_mattn_go_sqlite3/sqlite3-binding.c)
Checking gopls server logs, there is the message:
Checking the folder, this package has a sqlite3-binding.c and a sqlite3-binding.h.
I can build the project without problem, but I can not use the
go to
feature for some functions because of this problem, which is quite annoying.Any help is appreciated.
The text was updated successfully, but these errors were encountered: