Skip to content

x/tools/gopls: support opening $GOPATH as well as $GOPATH/src #46489

@ybaldus

Description

@ybaldus

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.15.6 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • Build info
      ----------
      golang.org/x/tools/gopls v0.6.11
      golang.org/x/tools/gopls@v0.6.11 h1:7S2k0xuVYc3secjy2uz0n+fGYxGJU6gXsLOmQ/r1HoI=
      github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
      github.com/google/go-cmp@v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
      github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
      golang.org/x/mod@v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
      golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
      golang.org/x/sys@v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
      golang.org/x/tools@v0.1.1-0.20210504170620-03ebc2c9fca8 h1:rTLms91GhM16y4sUcNGLdel0jJ8jXdQeXuN+7evgYiQ=
      golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
      honnef.co/go/tools@v0.1.3 h1:qTakTkI6ni6LFD5sBwwsdSO+AQqbSIxOauHTTQKZ/7o=
      mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
      mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.56.2 054a9295330880ed74ceaedda236253b4f39a335 x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.25.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/ybaldus/projects/reference-test:/home/ybaldus/projects/reference-test/vendor
GOROOT: /home/ybaldus/.asdf/installs/golang/1.15.6/go
PATH: /home/ybaldus/.asdf/installs/nodejs/12.13.1/.npm/bin:/home/ybaldus/.asdf/shims:/home/ybaldus/.asdf/bin:/home/ybaldus/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

   gopkgs: /home/ybaldus/projects/reference-test/bin/gopkgs installed
   go-outline: /home/ybaldus/projects/reference-test/bin/go-outline installed
   gotests: /home/ybaldus/projects/reference-test/bin/gotests installed
   gomodifytags: /home/ybaldus/projects/reference-test/bin/gomodifytags installed
   impl: /home/ybaldus/projects/reference-test/bin/impl installed
   goplay: /home/ybaldus/projects/reference-test/bin/goplay installed
   dlv: /home/ybaldus/projects/reference-test/bin/dlv installed
   dlv-dap: /home/ybaldus/projects/reference-test/bin/dlv-dap installed
   staticcheck: /home/ybaldus/projects/reference-test/bin/staticcheck installed
   gopls: /home/ybaldus/projects/reference-test/bin/gopls installed

go env
Workspace Folder (reference-test): /home/ybaldus/projects/reference-test
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/home/ybaldus/.cache/go-build"
	GOENV="/home/ybaldus/.config/go/env"
	GOEXE=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="linux"
	GOINSECURE=""
	GOMODCACHE="/home/ybaldus/projects/reference-test/pkg/mod"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/home/ybaldus/projects/reference-test:/home/ybaldus/projects/reference-test/vendor"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/home/ybaldus/.asdf/installs/golang/1.15.6/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/home/ybaldus/.asdf/installs/golang/1.15.6/go/pkg/tool/linux_amd64"
	GCCGO="gccgo"
	AR="ar"
	CC="gcc"
	CXX="g++"
	CGO_ENABLED="1"
	GOMOD=""
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build668739514=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

    "go.toolsManagement.autoUpdate": true,
    "go.testFlags": [
        "-v"
    ],

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. Open a workspace without open editors
  2. Open any file in a package from which something is referenced
  3. Try to find all refrences
  4. You will see only references inside the same package
  5. Open a file from another package where the reference is used
  6. Retry to find all references
  7. You will see everything

My minimal example:
image

Trying to find references:
image

The other file/package:
image

Second attempt to find references:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions