Skip to content

Bogus error reporting when module is in a subdir of workspace #3013

@pasckosky

Description

@pasckosky

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

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

    • 1.79.2
      695af097c7bd098fbf017ce3ac85e09bbc5dda06
      x64
  • Check your installed extensions to get the version of the VS Code Go extension

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

    • go: /usr/local/bin/go: go version go1.21.0 linux/amd64

    gotests: not installed
    gomodifytags: not installed
    impl: /home/pascky/go/bin/impl (version: v1.1.0 built with go: go1.21.0)
    goplay: not installed
    dlv: /home/pascky/go/bin/dlv (version: v1.21.0 built with go: go1.21.0)
    staticcheck: /home/pascky/go/bin/staticcheck (version: v0.4.6 built with go: go1.21.0)
    gopls: /home/pascky/go/bin/gopls (version: v0.13.2 built with go: go1.21.0)

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.

No modifications

Describe the bug

A clear and concise description of what the bug.
A clear and concise description of what you expected to happen.

Situation:
Directory with

  • configs (some yml files)
  • python (some tools for internal management)
  • resource (some resource files for internal management)
  • go (directory with the module and golang code -- go.mod file is in here)
  • (entually other modules that are not sharing any file among them)

Problem:
VSCode is not identifying correctly source of packages until I add go directory directly to workspace and work from there
Opening files, I get lots of bogus error reports and complains about not opening from the module root.
Compiler works correctly without any warning or error, proof that errors are mistakenly reported
Code navigation is broken too, Cannot go to, for example, to definition of any symbol

Expected:
since the whole code is in the go directory, all the symbol resultion and debugging should start from the position of the go.mod file.
Having several parallel go directorty must consider each module directory with its own go.mod as separate

Steps to reproduce the behavior:

  1. Create a go module or get an existing go module
  2. Create new workspace
  3. Add go module's parent directory to workspace instead of go module directory
  4. See all the bogus error shown in red by clicking any go file

Screenshots or recordings

no screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions