Skip to content

x/tools/gopls: Extension is having trouble with one package in a big project (the rest of the packages are fine) #73933

Open
@oakad

Description

@oakad

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.24.3 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

    • golang.org/x/tools/gopls v0.18.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

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

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

    • go: /opt/homebrew/bin/go: go version go1.24.3 darwin/arm64

    gopls: /Users/oakad/go/bin/gopls (version: v0.18.1 built with go: go1.24.1)
    gotests: /Users/oakad/go/bin/gotests (version: v1.6.0 built with go: go1.24.1)
    gomodifytags: /Users/oakad/go/bin/gomodifytags (version: v1.17.0 built with go: go1.24.1)
    impl: /Users/oakad/go/bin/impl (version: v1.4.0 built with go: go1.24.1)
    goplay: /Users/oakad/go/bin/goplay (version: v1.0.0 built with go: go1.24.1)
    dlv: /Users/oakad/go/bin/dlv (version: v1.24.1 built with go: go1.24.1)
    staticcheck: /Users/oakad/go/bin/staticcheck (version: v0.6.1 built with go: go1.24.1)

Share the Go related settings you have added/edited

"go.lintOnSave": "off",
"[go]": {
"editor.formatOnSave": false
},
"go.toolsManagement.autoUpdate": true,

Describe the bug

I have multiple multi-package Go projects. They generally work fine (autocomplete, go to definition, the usual stuff).

However, one of the packages in the multi project workspace is consistently misbehaving. All the imports in the said package are highlighted with red line:

could not import bytes (missing metadata for import of "bytes")compiler[BrokenIImport]
could not import time (missing metadata for import of "time")compiler[BrokenImport]

And so on.

There are only 3 source files (all smaller than 500 lines) in the said package and yet types defined in one of the files are highlighted with red lines in the other files ([UndeclaredName] errors). The extension tries to do things with those files but lags badly, it appears to be struggling.

Interestingly enough, if I hover a mouse over the package name in the package statement, only one file shows a correct package path. The rest 2 files confuse the correct package path with one of the imported dependencies.

All other packages and files in this and other projects work fine. It's just that one package, which compiles and works fine and otherwise looks like nothing special which is somehow causing an issue for the extension.

The issue manifests itself on multiple machines (MacOS and Linux). Deleting gopls cache, reinstalling tools is not helpful. There's nothing specific in the gopls log.

Steps to reproduce the behavior:

No idea. This one package in one project appears to be somehow bad, while everything else is fine.

I understand that there's not much to go by in this report, but may be somebody can give me some advice on how to diagnose the issue further.

Unfortunately, the package source is commercial and confidential in nature so I cannot share it.

Screenshots or recordings

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone 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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions