golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.8k stars 730 forks source link

Wrong inlay hints of unsafe.Sizeof(AType{}) #3146

Closed HwHgoo closed 6 months ago

HwHgoo commented 6 months ago

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_. - * Check your installed extensions to get the version of the VS Code Go extension -

Describe the bug

Inlay hint shows wrong value of unsafe.Sizeof(AType{}). And it only occurs when AType has an auto padding at the end.

Steps to reproduce the behavior:

See the screenshot.

Screenshots or recordings

image

HwHgoo commented 6 months ago

I think it should blame to gopls: image

hyangah commented 6 months ago

@HwHgoo thanks for the report. Can you please try the gopls with go1.22rc1? I think this is fixed in go1.22. (https://github.com/golang/go/issues/61035)

HwHgoo commented 6 months ago

@HwHgoo thanks for the report. Can you please try the gopls with go1.22rc1? I think this is fixed in go1.22. (golang/go#61035)

version image

It seems go1.22rc1 doesn't fix it as expected. I don't know if I'm doing right: I build the go1.22rc and override the path of go which originally is /usr/bin/go by simply doing export PATH=$PATH_TO_GO1.22rc1:$PATH.

hyangah commented 6 months ago

@HwHgoo Can you check what version of go was used to build the gopls?

gopls -v version

Or, use the Go explorer UI to inspect the tools versions.

Screenshot 2024-01-23 at 10 25 07 AM

If it's not built with go1.22rc1, run "Go: Install/Update Tools".

HwHgoo commented 6 months ago

Yes it's fixed. image But it's confusing that even I do export PATH=$PATH_TO_GO122rc1:$PATH, /usr/bin/go is used when I run go install golang.org/x/tools/gopls@latest. Thank you for replies.