Skip to content

x/tools/gopls: instead of hard-coded a link to pkgsite, provide link to definition if the symbol is local (defined in the same module) #80016

Description

@K9gam

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.26.3 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • zsh: command not found: gopls
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.123.2
      3c631b164c239e7aeaaae7c626b46c527b361af2
      x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.52.2
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • Tools Configuration

Environment

GOBIN: undefined
toolsGopath:
gopath: /home/user/go
GOROOT: /usr/local/go
PATH: /home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/var/cfengine/bin:/usr/local/go/bin

Tools

go:	/usr/local/go/bin/go: go version go1.26.3 linux/amd64

gotests:	not installed
impl:	not installed
goplay:	not installed
dlv:	not installed
gopls:	/home/user/go/bin/gopls	(version: v0.22.0 built with go: go1.26.3)

Go env

Workspace Folder (mygit): /home/user/repos/mygit

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build825909314=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/mnt/build/repos/mygit/go.mod'
GOMODCACHE='/home/user/go/pkg/mod'
GONOPROXY='/home/user/repos/mygit/pkg/xxx'
GONOSUMDB='/home/user/repos/mygit/pkg/xxx'
GOOS='linux'
GOPATH='/home/user/go'
GOPRIVATE='/home/user/repos/mygit/pkg/xxx'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.3'
GOWORK=''
PKG_CONFIG='pkg-config'

Share the Go related settings you have added/edited

None

Describe the bug

When hovering mouse pointer over a private package in the VS editor, it suggests documentation link on pkg.go.dev.

Acting by suggestion from https://github.com/golang/vscode-go/wiki/settings#uidocumentationlinktarget and trying to set GOPRIVATE environment variable to github path for the private package or to the local filesystem path for it gives no change in hovering behavior.

I'm working inside a workspace and private package is located as ./pkg/xxx.

Expected fix would be at least to hide the link in order to not mislead with providing links to pkg.go.dev for local/private packages.
Ideally the link should point to the correct package location.

Steps to reproduce the behavior:

  1. Hover mouse pointer over a private package name in VS Code editor.
  2. Notice the documentation link points to pkg.go.dev.

Screenshots or recordings

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.goplsIssues related to the Go language server, gopls.

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions