-
Notifications
You must be signed in to change notification settings - Fork 797
Go in vscode on WSL2 "forgets" that globals exist #897
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
Comments
@napei thanks for the issue report. Did you open the project folder (where I am not yet sure @stamblerre can you please take a look at the trace? The trace looks different from usual gopls trace I am familiar with. I.e. no gopls version, go env results... |
Yes the project is opened in vscode where Gopls seems to work most of the time with bazel from what I can see. This is an occasional issue that sometimes is triggered from a syntax error, but then it doesn't go away. I'm not sure though as I can't find a concrete way to repro this consistently. As far as bazel is concerned I don't think that should affect anything, as it just builds and links with extra steps; the source code is still there as normal. It just allows me to build a monorepo easier.
From what I know, that's built output from bazel, but I'm not sure why it's in the trace as that's not seen to me in the IDE as it's a symlink in the root directory that is ignored specifically for bazel things. Go itself also ignores symlinks. This is where bazel builds to I believe, and where some things get cached but I don't think it's supposed to be parsed. When I run
I copied it from the EDIT: Just realied I should clarify, the log I put here does not experience the bug it just has env info and version info. When this happens again I'll try to get a log again. I will note I am also using https://github.com/facebook/ent which means there's currently 47,268 lines of code in the |
My guess is that the issue has to do with the lack of Bazel support in Until |
@stamblerre is there a way I can tell As far as I know, it should never know about or look at code inside those directories as it's a cache from bazel not the true source code I'm working on. Could the excludes in vscode filter down to gopls somehow? |
But in general, |
Interesting. I think my case is different as there is nothing at all in the symlink direcrories that gopls should need to know about i.e. I'm not doing any codegen outside of the workspace. It's literally just a line-for-line copy of the workspace code in there, but only ever kept up to date when |
If you can provide a complete log when you see the failure, I can try to understand the issue more specifically--I'm just making guesses based on my experience with Bazel. |
@stamblerre I managed to get a trace which contains errors for you. https://pastebin.com/raw/hpanfixE Apologies for the length, I left vscode open for a while and then went back to it and updated bazel dependency files which seems to have caused this. It appears that running a bazel build to update those output files and restarting the language server helps to fix it, but that's not concrete. |
This indicates to me that there are clearly some missing definitions that From the logs, it looks like Going to close this in favor of golang/go#37205. Sorry about the inconvenience! |
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Gogo version go1.15.4 linux/amd64
code -v
orcode-insiders -v
to get version of VS Code or VS Code InsidersVersion: 0.18.1
go env
to get the go development environment detailsgo env output
``` GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/napei/.cache/go-build" GOENV="/home/napei/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/napei/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/napei/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/napei/vic/vicrewards-backend/go.mod" 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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build035989416=/tmp/go-build -gno-record-gcc-switches" ```Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Share all the settings with the
go.
or["go"]
orgopls
prefixes.Describe the bug
When working in a nested folder structure, go sometimes "forgets" about globals declared in main. Everything compiles fine, and autocomplete is aware of globals but sometimes after a few seconds vscode will decide that anything declared in
package main
doesn't exist anymore. I use WSL2 for development due to needing to use Bazel, so I'm not sure if this happens on windows or not. This has been going on for quite a while, but I've sort of put up with it. I used the Go Nightly extension for a while which it also happened in.My folder structure is kind of like this, using bazel as well. Everything works perfectly fine except for the IDE.
I can't share a proper repro as this is a company project. Ignoring the libs folder (just an example) variables in
package main
declared likevar foo bool
outside of functions are the culprit.Reloading vscode fixes it for about 30 seconds until it comes back again.
This only happens with the file open in the editor, and even with every go file in the project open in the editor it still happens.
Screenshots or recordings
gopls logs: https://pastebin.com/raw/RKFPwmb0
For example in



helpers.go
the following occurs, even thoughrmq
is defined inqueue.go
under the samepackage main
Some other things are defined in
main.go
The text was updated successfully, but these errors were encountered: