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: vendored modules ignored #55995

Open
andig opened this issue Oct 2, 2022 · 9 comments
Open

x/tools/gopls: vendored modules ignored #55995

andig opened this issue Oct 2, 2022 · 9 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

@andig
Copy link
Contributor

andig commented Oct 2, 2022

What version of Go are you using (go version)?

$ go version
go version go1.19.1 darwin/arm64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/andig/Library/Caches/go-build"
GOENV="/Users/andig/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andig/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andig/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.19.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.19.1/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/andig/htdocs/evcc/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build1385780622=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.19.1 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.19.1
uname -v: Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101
ProductName:	macOS
ProductVersion:	12.6
BuildVersion:	21G115
lldb --version: lldb-1400.0.30.3
Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)

What did you do?

Using VScode with latest Go plugin. Modules vendored in order to be able to patch x/crypto. During debug session, I can see that the code from the vendored module is executed.

What did you expect to see?

During browsing the code I expect drilldown on function to open vendored file.

What did you see instead?

Instead, file from module cache is opened, i.e. vendored dependencies ignored.

@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 Oct 2, 2022
@gopherbot gopherbot added this to the Unreleased milestone Oct 2, 2022
@andig
Copy link
Contributor Author

andig commented Oct 2, 2022

Screenshot from debugging:

Screenshot 2022-10-02 at 13 36 28

Screenshot from browsing:

Screenshot 2022-10-02 at 13 20 07

@suzmue
Copy link
Contributor

suzmue commented Oct 3, 2022

Hi @andig! Thanks for filing an issue. Would you mind sharing the following information about your VS Code related settings? Thanks!

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.
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
  • Check your installed extensions to get the version of the VS Code Go extension
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

@suzmue suzmue added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 3, 2022
@andig
Copy link
Contributor Author

andig commented Oct 4, 2022

Here we go:

  • Run go version to get version of Go from the VS Code integrated terminal:

    go version go1.19.1 darwin/arm64 (as above)
    
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

Build info
----------
golang.org/x/tools/gopls v0.9.5
    golang.org/x/tools/gopls@v0.9.5 h1:F3TO5th6TUg40FHrpxZfMkMlVaaTmByeEvylgVHGH2A=
    github.com/BurntSushi/toml@v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
    github.com/google/go-cmp@v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
    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-20220722155223-a9213eeb770e h1:7Xs2YCOpMlNqSQSmrrnhlzBXIE/bpMecZplbLePTJvE=
    golang.org/x/mod@v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
    golang.org/x/sync@v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
    golang.org/x/sys@v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
    golang.org/x/text@v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
    golang.org/x/tools@v0.1.13-0.20220908144252-ce397412b6a4 h1:glzimF7qHZuKVEiMbE7UqBu44MyTjt5u6j3Jz+rfMRM=
    golang.org/x/vuln@v0.0.0-20220901221904-62b0186a1058 h1:YnB27EXBD8XxB0JcaOeluuvhF2kS4DrH0k+lpopG2xc=
    honnef.co/go/tools@v0.3.2 h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=
    mvdan.cc/gofumpt@v0.3.1 h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8=
    mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.19.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    Not found- it's always the latest stable.

  • Check your installed extensions to get the version of the VS Code Go extension

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

    Checking configured tools....
    GOBIN: undefined
    toolsGopath: 
    gopath: /Users/andig/go
    GOROOT: /opt/homebrew/Cellar/go/1.19.1/libexec
    PATH: /Users/andig/go/bin:/opt/homebrew/opt/node@16/bin:/Users/andig/go/bin:/opt/homebrew/bin/go:/opt/homebrew/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/share/dotnet:/usr/local/munki:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:

        go:	/opt/homebrew/bin/go: go version go1.19.1 darwin/arm64

        gotests:	not installed
        gomodifytags:	not installed
        impl:	not installed
        goplay:	not installed
        dlv:	/Users/andig/go/bin/dlv	(version: v1.9.0 built with go: go1.19)
        staticcheck:	/Users/andig/go/bin/staticcheck	(version: v0.3.3 built with go: go1.19)
        gopls:	/Users/andig/go/bin/gopls	(version: v0.9.5 built with go: go1.19.1)

    go env
    Workspace Folder (evcc): /Users/andig/htdocs/evcc
        GO111MODULE=""
        GOARCH="arm64"
        GOBIN=""
        GOCACHE="/Users/andig/Library/Caches/go-build"
        GOENV="/Users/andig/Library/Application Support/go/env"
        GOEXE=""
        GOEXPERIMENT=""
        GOFLAGS=""
        GOHOSTARCH="arm64"
        GOHOSTOS="darwin"
        GOINSECURE=""
        GOMODCACHE="/Users/andig/go/pkg/mod"
        GONOPROXY=""
        GONOSUMDB=""
        GOOS="darwin"
        GOPATH="/Users/andig/go"
        GOPRIVATE=""
        GOPROXY="https://proxy.golang.org,direct"
        GOROOT="/opt/homebrew/Cellar/go/1.19.1/libexec"
        GOSUMDB="sum.golang.org"
        GOTMPDIR=""
        GOTOOLDIR="/opt/homebrew/Cellar/go/1.19.1/libexec/pkg/tool/darwin_arm64"
        GOVCS=""
        GOVERSION="go1.19.1"
        GCCGO="gccgo"
        AR="ar"
        CC="clang"
        CXX="clang++"
        CGO_ENABLED="1"
        GOMOD="/Users/andig/htdocs/evcc/go.mod"
        GOWORK=""
        CGO_CFLAGS="-g -O2"
        CGO_CPPFLAGS=""
        CGO_CXXFLAGS="-g -O2"
        CGO_FFLAGS="-g -O2"
        CGO_LDFLAGS="-g -O2"
        PKG_CONFIG="pkg-config"
        GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build2167020156=/tmp/go-build -gno-record-gcc-switches -fno-common"
        
    Workspace Folder (cloud): /Users/andig/htdocs/cloud
        GO111MODULE=""
        GOARCH="arm64"
        GOBIN=""
        GOCACHE="/Users/andig/Library/Caches/go-build"
        GOENV="/Users/andig/Library/Application Support/go/env"
        GOEXE=""
        GOEXPERIMENT=""
        GOFLAGS=""
        GOHOSTARCH="arm64"
        GOHOSTOS="darwin"
        GOINSECURE=""
        GOMODCACHE="/Users/andig/go/pkg/mod"
        GONOPROXY=""
        GONOSUMDB=""
        GOOS="darwin"
        GOPATH="/Users/andig/go"
        GOPRIVATE=""
        GOPROXY="https://proxy.golang.org,direct"
        GOROOT="/opt/homebrew/Cellar/go/1.19.1/libexec"
        GOSUMDB="sum.golang.org"
        GOTMPDIR=""
        GOTOOLDIR="/opt/homebrew/Cellar/go/1.19.1/libexec/pkg/tool/darwin_arm64"
        GOVCS=""
        GOVERSION="go1.19.1"
        GCCGO="gccgo"
        AR="ar"
        CC="clang"
        CXX="clang++"
        CGO_ENABLED="1"
        GOMOD="/Users/andig/htdocs/cloud/go.mod"
        GOWORK=""
        CGO_CFLAGS="-g -O2"
        CGO_CPPFLAGS=""
        CGO_CXXFLAGS="-g -O2"
        CGO_FFLAGS="-g -O2"
        CGO_LDFLAGS="-g -O2"
        PKG_CONFIG="pkg-config"
        GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build2498289659=/tmp/go-build -gno-record-gcc-switches -fno-common"
        
    Workspace Folder (api): /Users/andig/htdocs/api
        GO111MODULE=""
        GOARCH="arm64"
        GOBIN=""
        GOCACHE="/Users/andig/Library/Caches/go-build"
        GOENV="/Users/andig/Library/Application Support/go/env"
        GOEXE=""
        GOEXPERIMENT=""
        GOFLAGS=""
        GOHOSTARCH="arm64"
        GOHOSTOS="darwin"
        GOINSECURE=""
        GOMODCACHE="/Users/andig/go/pkg/mod"
        GONOPROXY=""
        GONOSUMDB=""
        GOOS="darwin"
        GOPATH="/Users/andig/go"
        GOPRIVATE=""
        GOPROXY="https://proxy.golang.org,direct"
        GOROOT="/opt/homebrew/Cellar/go/1.19.1/libexec"
        GOSUMDB="sum.golang.org"
        GOTMPDIR=""
        GOTOOLDIR="/opt/homebrew/Cellar/go/1.19.1/libexec/pkg/tool/darwin_arm64"
        GOVCS=""
        GOVERSION="go1.19.1"
        GCCGO="gccgo"
        AR="ar"
        CC="clang"
        CXX="clang++"
        CGO_ENABLED="1"
        GOMOD="/Users/andig/htdocs/api/go.mod"
        GOWORK=""
        CGO_CFLAGS="-g -O2"
        CGO_CPPFLAGS=""
        CGO_CXXFLAGS="-g -O2"
        CGO_FFLAGS="-g -O2"
        CGO_LDFLAGS="-g -O2"
        PKG_CONFIG="pkg-config"
        GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build2133126525=/tmp/go-build -gno-record-gcc-switches -fno-common"
  • Share the Go related settings you have added/edited
    "go.gopath": "~/go",
    "go.useLanguageServer": true,
    "gopls": {
        // "formatting.gofumpt": true,
    },
    "go.languageServerFlags": [
        "serve",
        "-rpc.trace",
        "--debug=localhost:6060"
    ],

I can probably convert the case into a small repro if that helps.

@suzmue suzmue removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 6, 2022
@suzmue suzmue modified the milestones: Unreleased, gopls/v0.10.0 Oct 6, 2022
@adonovan
Copy link
Member

adonovan commented Nov 28, 2022

Hi @andig, thanks for reporting this bug. Could you clarify what you meant by "drilldown on function"? Is this the go-to-definition operation?

I tried downloading a project, adding a dependency on the crypto module, vendoring the dependencies, then jumping to the definition of the crypto symbol whose reference I had inserted, and gopls correctly visited the vendored code. I don't doubt that gopls has several bugs related to vendoring, but I'm not able to reproduce this one yet.

Is your project open-source? If so, please share details of specific commands and files and I'll try to reproduce it. If it's not open-source, would you be willing to try creating a reproducible test case using open-source code? As soon as we can reproduce the issue we can attempt a fix. Thanks!

@adonovan
Copy link
Member

adonovan commented Nov 28, 2022

Never mind! I was able to reproduce it by loading the workspace, then running go mod vendor, and then looking up the symbol: gopls retained the old declaration, incorrectly. (Running go mod vendor before loading the workspace, or restarting gopls, causes it to see the correct declaration in vendor/.)

@andig
Copy link
Contributor Author

andig commented Nov 28, 2022

I‘m sorry, forgot to close this one. These are modules of the standard library vendored. They do not become part of the build as I‘ve later found out. So gopls performs perfectly ok.

@andig andig closed this as completed Nov 28, 2022
@andig
Copy link
Contributor Author

andig commented Nov 28, 2022

Reopening as you‘ve found a different issue which might still be tracked here.

@andig andig reopened this Nov 28, 2022
@adonovan
Copy link
Member

adonovan commented Nov 28, 2022

I‘m sorry, forgot to close this one. These are modules of the standard library vendored. They do not become part of the build as I‘ve later found out. So gopls performs perfectly ok.

Your example refers to golang.org/x/crypto, which is not part of the standard library. This is indeed a bug, one I can reproduce.

@andig
Copy link
Contributor Author

andig commented Nov 28, 2022

See https://groups.google.com/g/golang-nuts/c/wlhj5RFXh9g/m/DRCjOLw9AQAJ?utm_medium=email&utm_source=footer where Ian confirmed that vendored x/crypto is not used.

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

5 participants