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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: nvim with go1.22 stopped working #66743

Closed
op opened this issue Apr 9, 2024 · 4 comments
Closed

x/tools/gopls: nvim with go1.22 stopped working #66743

op opened this issue Apr 9, 2024 · 4 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@op
Copy link

op commented Apr 9, 2024

What did you do?

I changed go.mod in a project to use go 1.22.2 and now the LSP integration with gopls for neovim stopped working.

Running GO111MODULE=off nvim makes gopls happy again.

What did you expect to see?

References to sources. 馃懐

What did you see instead?

Error when executing textDocument/references : no object found for "MyStruct"

This is what trace gave me:

    13:59:33.241 end textDocument/references (+2.617523877s) method="textDocument/references" direction="in" id="#5"
        13:59:33.241 event (+2.617520418s) label= status.code="OK" 
        13:59:30.624 start queued
        13:59:33.240 end queued (+2.616936504s)
        13:59:33.241 start lsp.Server.references URI=file:///home/orion/src/github.com/[..]/file.go
        13:59:33.241 end lsp.Server.references (+206.982碌s) URI=file:///home/orion/src/github.com/[..]/file.go
            13:59:33.241 start golang.references
            13:59:33.241 end golang.references (+161.379碌s)
                13:59:33.241 start cache.ParseGoSrc file="/home/orion/src/github.com/[..]/file.go"
                13:59:33.241 end cache.ParseGoSrc (+50.929碌s) file="/home/orion/src/github.com/[..]/file.go"
                13:59:33.241 start cache.forEachPackage packages=0
                13:59:33.241 end cache.forEachPackage (+12.649碌s) packages=0

This is the trace running with GO111MODULE=off nvim:

    13:58:00.802 end textDocument/references (+2.363171265s) method="textDocument/references" direction="in" id="#5"
        13:58:00.802 event (+2.363167136s) label= status.code="OK" 
        13:57:58.439 start queued
        13:58:00.792 end queued (+2.353172048s)
        13:58:00.792 start lsp.Server.references URI=file:///home/orion/src/github.com/[..]/file.go
        13:58:00.802 end lsp.Server.references (+9.50709ms) URI=file:///home/orion/src/github.com/[..]/file.go
            13:58:00.792 start golang.references
            13:58:00.802 end golang.references (+9.473549ms)
                13:58:00.792 start cache.ParseGoSrc file="/home/orion/src/github.com/[..]/file.go"
                13:58:00.792 end cache.ParseGoSrc (+47.099碌s) file="/home/orion/src/github.com/[..]/file.go"
                13:58:00.792 start cache.forEachPackage packages=0
                13:58:00.792 end cache.forEachPackage (+106.433碌s) packages=0
                13:58:00.792 start cache.snapshot.References
                13:58:00.792 end cache.snapshot.References (+26.739碌s)
                    13:58:00.792 start cache.forEachPackage packages=0
                    13:58:00.792 end cache.forEachPackage (+6.675碌s) packages=0
                13:58:00.792 start cache.forEachPackage packages=0
                13:58:00.793 end cache.forEachPackage (+36.98碌s) packages=0
                13:58:00.792 start cache.forEachPackage packages=1
                13:58:00.801 end cache.forEachPackage (+8.214685ms) packages=1
                    13:58:00.794 start cache.typeCheckBatch.checkPackage package="github.com/[..]/fleetservice.test]"
                    13:58:00.801 end cache.typeCheckBatch.checkPackage (+6.864903ms) package="github.com/[..]/fleetservice [github.com/northvolt/[..]/fleetservice.test]"
                        13:58:00.794 start cache.ParseGoSrc file="/home/orion/src/github.com/[..]/other_file.go"
                        13:58:00.794 end cache.ParseGoSrc (+183.399碌s) file="/home/orion/src/github.com/[..]/other_file.go"

Build info

golang.org/x/tools/gopls v0.15.2
    golang.org/x/tools/gopls@v0.15.2 h1:4JKt4inO8JaFW3l/Fh9X1k/5JQn+iUOpdc4/Lpi0mOs=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
    golang.org/x/sync@v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
    golang.org/x/telemetry@v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
    golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
    golang.org/x/tools@v0.18.1-0.20240311201521-78fbdeb61842 h1:No0LMXYFkp3j4oEsPdtY8LUQz33gu79Rm9DE+izMeGQ=
    golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
    honnef.co/go/tools@v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
    mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.21.1
@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 Apr 9, 2024
@gopherbot gopherbot added this to the Unreleased milestone Apr 9, 2024
@seankhliao
Copy link
Member

have you tried building gopls with go1.22.2?

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 9, 2024
@op
Copy link
Author

op commented Apr 9, 2024

Sorry, my bad. Within nvim, mason had its own version of gopls (v0.11). Running :MasonInstall gopls fixed this for me.

@op op closed this as completed Apr 9, 2024
@arodland
Copy link

So with auto toolchain, is this going to be a problem every time you open up a codebase that declares a go version newer than the system-wide go that you built gopls with? Is there any way it could at least provide a more informative error?

@op
Copy link
Author

op commented Apr 11, 2024

@arodland the version of the compiler didn't matter in this case. Adding a minimum version check sounds like a good idea. That logic might need to be added in the editor though. I'll look into fixing that for nvim. Hopefully others have upgraded already. gopls v0.11 came out during Go 1.19.

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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants