Skip to content

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

Closed
@op

Description

@op

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

Activity

added
ToolsThis label describes issues relating to any tools in the x/tools repository.
goplsIssues related to the Go language server, gopls.
on Apr 9, 2024
added this to the Unreleased milestone on Apr 9, 2024
seankhliao

seankhliao commented on Apr 9, 2024

@seankhliao
Member

have you tried building gopls with go1.22.2?

added
WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
on Apr 9, 2024
op

op commented on Apr 9, 2024

@op
ContributorAuthor

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

arodland

arodland commented on Apr 11, 2024

@arodland

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

op commented on Apr 11, 2024

@op
ContributorAuthor

@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.

locked and limited conversation to collaborators on Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @arodland@op@gopherbot@seankhliao

        Issue actions

          x/tools/gopls: nvim with go1.22 stopped working · Issue #66743 · golang/go