Closed xiazemin closed 2 years ago
% go version go version go1.18beta2 darwin/arm64
golang.org/x/tools/gopls v0.8.0 golang.org/x/tools/gopls@v0.8.0 h1:a71KO95TfIvCCMQJrZBSQIGQ9lkc0kWL+dSlEdZd7HI= github.com/BurntSushi/toml@v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= 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.10-0.20220303153236-fa15af63a6f1 h1:UVkOvSIhR/pX6OflsXS9hsDvaUJn8SLHqTlvdfUDiNo= golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= honnef.co/go/tools@v0.2.2 h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1xvnzk= mvdan.cc/gofumpt@v0.3.0 h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4= mvdan.cc/xurls/v2@v2.3.0 h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I= go: go1.18beta2
% code -v 1.65.0 b5205cc8eb4fbaa726835538cd82372cc0222d43 x64
undeclared name: comparable (requires version go1.18 or later)
Can you run "Go: Locate Configured Go Tools" command and check if the extension chose the right go version (1.18)?
go
chosen from the terminal may be different from the go
used by the extension depending on how your login shell is configured or how the vscode program was launched.
Checking configured tools.... GOBIN: undefined toolsGopath: gopath: /Users/xiazemin/.gvm/pkgsets/go1.18beta2/global GOROOT: /Users/xiazemin/.gvm/gos/go1.18beta2 PATH: /Users/xiazemin/.gvm/gos/go1.18beta2/bin:/opt/homebrew/opt/openssl@1.1/bin:/Users/xiazemin/.gvm/pkgsets/go1.18beta2/global/bin:/Users/xiazemin/.gvm/pkgsets/go1.18beta2/global/overlay/bin:/Users/xiazemin/.gvm/bin:/Users/xiazemin/.gvm/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/go/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/xiazemin/go/bin:/Users/xiazemin/source/etcd/bin:/Users/xiazemin/go/FlameGraph:/Users/xiazemin/source/k8s_learn/Istio/istio-1.12.1/bin PATH (vscode launched with): /opt/homebrew/opt/openssl@1.1/bin:/Users/xiazemin/.gvm/pkgsets/go1.18beta2/global/bin:/Users/xiazemin/.gvm/gos/go1.18beta2/bin:/Users/xiazemin/.gvm/pkgsets/go1.18beta2/global/overlay/bin:/Users/xiazemin/.gvm/bin:/Users/xiazemin/.gvm/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/go/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/xiazemin/go/bin:/Users/xiazemin/source/etcd/bin:/Users/xiazemin/go/FlameGraph:/Users/xiazemin/source/k8s_learn/Istio/istio-1.12.1/bin
go: /Users/xiazemin/.gvm/gos/go1.18beta2/bin/go: go version go1.18beta2 darwin/arm64
Thanks. @xiazemin Did you update your go.mod file to use go1.18 language feature?
gopls
side work to offer a quickfix to recommend the right language version when it sees the new language feature (https://github.com/golang/go/issues/51086) is in progress.
If that's the cause of the issue, run go mod edit -go 1.18
Otherwise, we need a reproducer example.
after I use
Go: Restart Language Server
Restart the running instance of the language server
it works for me
@xiazemin I am confused. Can you clarify if the issue was due to the go version statement in go.mod
, or due to a non-deterministic bug that's somehow cleared up by restarting a gopls (without any code/go.mod change)?
cleared up by restarting a gopls (without any code/go.mod change)
Thanks.
I guess some transient version mismatch made gopls to report the issue, but, unfortunately, I don't see a path to investigate further without an example to reproduce the problem. Closing.
I have met this issue too, but i solved it by upgrade my gopls version to the latest.Hope that will help the other people who have met the same problem.
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
* Run `go version` to get version of Go from _the VS Code integrated terminal_. -
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 thego.
or["go"]
orgopls
prefixes.Describe the bug
A clear and concise description of what the bug. A clear and concise description of what you expected to happen.
Steps to reproduce the behavior:
Screenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.