Skip to content
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: #52641

Closed
cyberbearwrites opened this issue May 1, 2022 · 3 comments
Closed

x/tools/gopls: #52641

cyberbearwrites opened this issue May 1, 2022 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@cyberbearwrites
Copy link

cyberbearwrites commented May 1, 2022

gopls version

Build info

golang.org/x/tools/gopls v0.8.3
golang.org/x/tools/gopls@v0.8.3 h1:Mxm94ix8oSARQ6svioO6SxKEYWT/VCP54/448LOHzrk=
github.com/google/go-cmp@v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/mod@v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sys@v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
golang.org/x/text@v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/tools@v0.1.11-0.20220407163324-91bcfb1bdf9c h1:rYiuK/jn6TCxjAq1hQ6MR6pgOeP3A5gIHDxgrQ8Vbys=
golang.org/x/vuln@v0.0.0-20220324005316-18fd808f5c7f h1:9dMzk88fnONra7zrEalqkRMGa9jMGf9B5mdzhYVyI28=
golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
mvdan.cc/gofumpt@v0.3.0 h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4=
mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.14.7

go env

GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/kali/.cache/go-build"
GOENV="/home/kali/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/kali/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/kali/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"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/usr/local/go/src/sync/atomic/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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build206143841=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I am a bit new to the Go Programming Language.

I upgraded Go to Version 1.81.

After upgrading, everything works perfectly fine except for this error in my VSCODE problems pane.

undeclared name: any (compile)

go

I did a bit of googling and all roads seem to lead to using go mod init

What did you expect to see?

Even after running

go mod init atomic

Hoping to resolve the error, problem still persist

In fact even when I try to run go mod tidy from vscode I get this when the file is actually there.
Maybe I'm doing this wrongly.

Command 'gopls.tidy' failed: Error: no go.mod file found in /usr/local/go/src/sync/atomic.

go2

Editor and settings

VSCODE; No setting were made relating to Go.

Logs

[Error - 15:57:04] 2022/05/01 15:57:04 DocumentSymbols failed: getting file for DocumentSymbols: no packages for non-Go file file:///usr/local/go/src/sync/atomic/go.mod (go.mod)
URI=file:///usr/local/go/src/sync/atomic/go.mod

EDIT: I've never used or opened this file(s) before, I just installed Go, opened vscode and the error appears.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels May 1, 2022
@gopherbot gopherbot added this to the Unreleased milestone May 1, 2022
@hyangah
Copy link
Contributor

hyangah commented May 1, 2022

Can u please run "Go: Install/update Tools" command and rebuild gopls with go1.18.x?

Wasn't there a notification to ask u to rebuild all tools? If not, that is a bug.

@cyberbearwrites
Copy link
Author

Can u please run "Go: Install/update Tools" command and rebuild gopls with go1.18.x?

Wasn't there a notification to ask u to rebuild all tools? If not, that is a bug.

Thanks for the responsive feedback.

There was a notification and I let it run.

Let me force it.

@cyberbearwrites
Copy link
Author

So I started by deleting the previously built gopls binary in my $GOPATH bin file

rm $GOPATH/bin/gopls

I also deleted staticcheck where it was previously installed on my computer so I can get a new binary built for Go 1.8.1(Although, I don't think it was necessary).

rm $GOPATH/bin/staticcheck

I also went ahead to delete the source files for gopls(I also think this too wasn't necessary).

rm -r $GOPATH/src/golang.org/x/tools/gopls

By installing gopls manually solved my problem

go get -v golang.org/x/tools/gopls

Although there could have been a better way to do this, this was what worked for me.

Thank you for your time hyangah

@suzmue suzmue closed this as completed May 2, 2022
@golang golang locked and limited conversation to collaborators May 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants