Skip to content

x/tools/gopls: disable package-oriented diagnostics for files/directories whose names begin with "."/"_" #60527

Description

@hyangah

Gopls version: v0.12.0

How to reproduce

  1. Clone and open the delve project (github.com/go-delve/delve). There should be no diagnostics.
  2. Open one of the files in _fixtures. Gopls is publishing ~570 compiler errors (mostly, DuplicateDecl)
  3. Close the file. The diagnostics don't go away.

The directory _fixtures contain various files used for debugging. Depending on debugging scenario, mostly a single file is chosen to be built and debugged by tests. They are like testdata.

According to the go command line doc https://pkg.go.dev/cmd/go#hdr-Package_lists_and_patterns files in this directory are handled specially. But gopls's behavior doesn't seem to align with it.

Directory and file names that begin with "." or "_" are ignored by the go tool, as are directories named "testdata".

I'd appreciate completion or single file mode diagnostics on the files, but not DuplicateDecl diagnostics.

Alternatives to consider

  • Provide an option to disable diagnostics on files in certain directories. -> Should this be editor's option?
  • Unpublish diagnostics once the files in _fixtures are all closed. -> Still distracting.
  • Ask users to use build tags. (//go:build ignore) -> at least, for delve, this will be a huge change since most tests are sensitive to file line number changes (e.g. setting breakpoint).

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions