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: hover doc doesn't show the receiver variable name #62190

Closed
willfaught opened this issue Aug 18, 2023 · 3 comments
Closed

x/tools/gopls: hover doc doesn't show the receiver variable name #62190

willfaught opened this issue Aug 18, 2023 · 3 comments
Assignees
Labels
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

@willfaught
Copy link
Contributor

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.
    • go version go1.21.0 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • Build info

golang.org/x/tools/gopls v0.13.2
golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=
github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
golang.org/x/mod@v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/sync@v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sys@v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/text@v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/tools@v0.11.2-0.20230810185051-cc6b5804b8cf h1:Oush7UwPamr2/iNeNFBuNFj89YyHn0YY69EKDdvANnk=
golang.org/x/vuln@v0.0.0-20230110180137-6ad3e3d07815 h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU=
honnef.co/go/tools@v0.4.2 h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=
mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.21.0

  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • 1.81.1
      6c3e3dba23e8fadc360aed75ce363ba185c49794
      x64
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.39.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

    • Checking configured tools....
      GOBIN: undefined
      toolsGopath:
      gopath: /Users/Will/Library/Application Support/go
      GOROOT: /usr/local/Cellar/go/1.21.0/libexec
      PATH: /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin:/Users/Will/Library/Application Support/go/bin

    go: /usr/local/bin/go: go version go1.21.0 darwin/amd64

    gotests: /Users/Will/Library/Application Support/go/bin/gotests (version: v1.6.0 built with go: go1.21.0)
    gomodifytags: /Users/Will/Library/Application Support/go/bin/gomodifytags (version: v1.16.0 built with go: go1.21.0)
    impl: /Users/Will/Library/Application Support/go/bin/impl (version: v1.1.0 built with go: go1.21.0)
    goplay: /Users/Will/Library/Application Support/go/bin/goplay (version: v1.0.0 built with go: go1.21.0)
    dlv: /Users/Will/Library/Application Support/go/bin/dlv (version: v1.21.0 built with go: go1.21.0)
    staticcheck: /Users/Will/Library/Application Support/go/bin/staticcheck (version: v0.4.5 built with go: go1.21.0)
    gopls: /Users/Will/Library/Application Support/go/bin/gopls (version: v0.13.2 built with go: go1.21.0)

go env
Workspace Folder (backend): /Users/Will/Developer/work/backend
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/Will/Library/Caches/go-build'
GOENV='/Users/Will/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/Will/Library/Application Support/go/pkg/mod'
GONOPROXY='github.com/FrontRowXP,github.com/frontrowxp'
GONOSUMDB='github.com/FrontRowXP,github.com/frontrowxp'
GOOS='darwin'
GOPATH='/Users/Will/Library/Application Support/go'
GOPRIVATE='github.com/FrontRowXP,github.com/frontrowxp'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/Cellar/go/1.21.0/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/Cellar/go/1.21.0/libexec/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/Will/Developer/work/backend/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/bx/qk0phsxd265fqj512dnnpg080000gn/T/go-build225606814=/tmp/go-build -gno-record-gcc-switches -fno-common'

Share the Go related settings you have added/edited

    "go.buildTags": "integration",
    "go.editorContextMenuCommands": {
        "testAtCursor": true,
        "testFile": true,
        "testPackage": true
    },
    "go.enableCodeLens": {
        "runtest": false
    },
    "go.formatTool": "goimports",
    "go.toolsManagement.autoUpdate": true,
    "gopls": {
        "ui.semanticTokens": true
    },

Describe the bug

Hover documentation doesn't show the receiver variable name, which is confusing if the documentation refers to it by name.

Steps to reproduce the behavior:

Write something like:

durationFloat := big.NewFloat(float64(duration))
durationFloat.Quo(durationFloat, big.NewFloat(60))

Hover over "Quo".

Screenshots or recordings

Screenshot 2023-08-17 at 10 57 00 PM
@willfaught
Copy link
Contributor Author

Now that I look at the screenshot some more, there's also a bug where it puts a period between the receiver and the method name.

@findleyr
Copy link
Contributor

Thanks @willfaught. This code is using go/types formatting for methods:
https://go.dev/play/p/TIMXVP3ZIVj

But you're right, it would be clearer to format the declaration exactly.

@findleyr findleyr changed the title Hover doc doesn't show the receiver variable name x/tools/gopls: hover doc doesn't show the receiver variable name Aug 21, 2023
@findleyr findleyr transferred this issue from golang/vscode-go Aug 21, 2023
@findleyr findleyr added this to the gopls/v0.15.0 milestone Aug 21, 2023
@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 Aug 21, 2023
@adonovan adonovan self-assigned this Dec 1, 2023
@gopherbot
Copy link

Change https://go.dev/cl/546735 mentions this issue: gopls/internal/lsp/source: improve method hover

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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