Skip to content

go1.18范型语法高亮错误 #2093

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

Closed
xiazemin opened this issue Mar 7, 2022 · 9 comments
Closed

go1.18范型语法高亮错误 #2093

xiazemin opened this issue Mar 7, 2022 · 9 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@xiazemin
Copy link

xiazemin commented Mar 7, 2022

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.
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
  • Check your installed extensions to get the version of the VS Code Go extension
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

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"] or gopls 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:

  1. Go to '...'
  2. Click on '....'
  3. See error

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

@gopherbot gopherbot added this to the Untriaged milestone Mar 7, 2022
@xiazemin
Copy link
Author

xiazemin commented Mar 7, 2022

% go version
go version go1.18beta2 darwin/arm64

% gopls -v version
Build info

golang.org/x/tools/gopls v0.8.0
golang.org/x/tools/[email protected] h1:a71KO95TfIvCCMQJrZBSQIGQ9lkc0kWL+dSlEdZd7HI=
github.com/BurntSushi/[email protected] h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
github.com/google/[email protected] h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/[email protected] h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/[email protected] h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/[email protected] h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
golang.org/x/[email protected] h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/[email protected] h1:UVkOvSIhR/pX6OflsXS9hsDvaUJn8SLHqTlvdfUDiNo=
golang.org/x/[email protected] h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
honnef.co/go/[email protected] h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1xvnzk=
mvdan.cc/[email protected] h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4=
mvdan.cc/xurls/[email protected] h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=
go: go1.18beta2

% code -v
1.65.0
b5205cc8eb4fbaa726835538cd82372cc0222d43
x64

undeclared name: comparable (requires version go1.18 or later)

@hyangah
Copy link
Contributor

hyangah commented Mar 7, 2022

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.

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 7, 2022
@xiazemin
Copy link
Author

xiazemin commented Mar 8, 2022

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/[email protected]/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/[email protected]/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

@hyangah
Copy link
Contributor

hyangah commented Mar 8, 2022

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 (golang/go#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.

@xiazemin
Copy link
Author

xiazemin commented Mar 8, 2022

after I use
Go: Restart Language Server
Restart the running instance of the language server

it works for me

@hyangah
Copy link
Contributor

hyangah commented Mar 8, 2022

@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)?

@xiazemin
Copy link
Author

cleared up by restarting a gopls (without any code/go.mod change)

@hyangah
Copy link
Contributor

hyangah commented Mar 10, 2022

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.

@hyangah hyangah closed this as completed Mar 10, 2022
@Shawn-Huang-Tron
Copy link

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.

@golang golang locked and limited conversation to collaborators Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants