Skip to content

x/tools/gopls: improve diagnostics for empty go files #42154

Open
@hyangah

Description

@hyangah

I propose not to generate diagnostics for the newly created, empty file.

Assume this user workflow:

  • mkdir hello; cd hello
  • run go mod init example.com/hello
  • open the folder from an editor (e.g. vscode with gopls enabled by default)
  • create a new file hello.go, using the editor's feature

The first thing the user will notice is a diagnostic error message.

[Trace - 17:35:12.131 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/hello/hello.go","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"severity":1,"source":"syntax","message":"expected ';', found 'EOF'"}]}

It's not a critical, major issue, but it's not nice nor useful to present an error message before the user starts typing anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions