golang / vscode-go

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

Goto Definition Action for imports also Unexpectedly Opens Documentation in Browser #3041

Closed niranjan94 closed 11 months ago

niranjan94 commented 11 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_. - `go version go1.21.3 linux/amd64` * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. - `v0.14.1` * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. ``` 1.84.2 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e 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: /home/redacted/go GOROOT: /home/linuxbrew/.linuxbrew/Cellar/go/1.21.3/libexec PATH: /home/redacted/.vscode-server/bin/1a5daa3a0231a0fbba4f14db7ec463cf99d7768e/bin/remote-cli:/home/redacted/.bun/bin:/home/redacted/.local/share/pnpm:/run/user/1000/fnm_multishells/1165889_1699615402877/bin:/home/redacted/.local/share/fnm:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/redacted/.pyenv/shims:/home/redacted/.pyenv/bin:/home/redacted/bin:/usr/local/bin:/home/redacted/.cargo/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/redacted/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/home/redacted/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git:/home/redacted/.antigen/bundles/zsh-users/zsh-syntax-highlighting:/home/redacted/.antigen/bundles/zsh-users/zsh-autosuggestions:/home/redacted/.antigen/bundles/zsh-users/zsh-completions go: /home/linuxbrew/.linuxbrew/bin/go: go version go1.21.3 linux/amd64 gotests: /home/redacted/go/bin/gotests (version: v1.6.0 built with go: go1.21.0) gomodifytags: /home/redacted/go/bin/gomodifytags (version: v1.16.0 built with go: go1.21.0) impl: /home/redacted/go/bin/impl (version: v1.1.0 built with go: go1.21.0) goplay: /home/redacted/go/bin/goplay (version: v1.0.0 built with go: go1.21.0) dlv: /home/redacted/go/bin/dlv (version: v1.21.0 built with go: go1.21.0) staticcheck: /home/redacted/go/bin/staticcheck (version: v0.4.5 built with go: go1.21.0) gopls: /home/redacted/go/bin/gopls (version: v0.14.1 built with go: go1.21.3) go env Workspace Folder (root): /home/redacted/projects/app/app-core GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/redacted/.cache/go-build' GOENV='/home/redacted/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/redacted/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/redacted/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/home/linuxbrew/.linuxbrew/Cellar/go/1.21.3/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/home/linuxbrew/.linuxbrew/Cellar/go/1.21.3/libexec/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.21.3' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOMOD='/dev/null' 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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2930060647=/tmp/go-build -gno-record-gcc-switches' Workspace Folder (api-global): /home/redacted/projects/app/app-core/api-global GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/redacted/.cache/go-build' GOENV='/home/redacted/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/redacted/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/redacted/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/home/linuxbrew/.linuxbrew/Cellar/go/1.21.3/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/home/linuxbrew/.linuxbrew/Cellar/go/1.21.3/libexec/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.21.3' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOMOD='/dev/null' 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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2151347667=/tmp/go-build -gno-record-gcc-switches' Workspace Folder (api-regional): /home/redacted/projects/app/app-core/api-regional GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/redacted/.cache/go-build' GOENV='/home/redacted/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/redacted/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/redacted/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/home/linuxbrew/.linuxbrew/Cellar/go/1.21.3/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/home/linuxbrew/.linuxbrew/Cellar/go/1.21.3/libexec/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.21.3' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOMOD='/home/redacted/projects/app/app-core/api-regional/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2075772077=/tmp/go-build -gno-record-gcc-switches' ```

Share the Go related settings you have added/edited

{
  "go.toolsManagement.autoUpdate": true,
  "gopls": {
    "ui.documentation.linksInHover": false
  }
}

Describe the bug

Trying to goto the definition/source of imports results in triggering of both the goto definition action (expected) and the opening of the documentation on the browser. (Screen-recording attached)

Steps to reproduce the behavior:

  1. Open any go project
  2. Do a cmd+click to goto the definition of any of the imports

Screenshots or recordings

https://github.com/golang/vscode-go/assets/2404372/891a0398-2f91-4e68-bc67-f5b7adcabd35

niranjan94 commented 11 months ago

Setting the following solves this. My bad for not digging into the settings more in detail.

"gopls.ui.navigation.importShortcut": "Definition"