Skip to content

x/tools/gopls: go/parser work-arounds #37451

Open
@stamblerre

Description

@stamblerre

This issue tracks all of the workarounds implemented in gopls to handle places where go/parser loses information. Most of this code can be found in golang.org/x/tools/internal/lsp/cache/parse.go and was written by @muirdm.

The current list of workarounds includes handling:

  • Missing curly braces in if statements (if foo -> if foo {})
  • Missing selectors (x. -> x._)
  • Partial identifiers that are keywords (foo.var -> foo._)
  • Missing conditional statements in if statements with initialization statements (if i := 0)
  • Unexpected array types ([]int -> []int{})
  • Incomplete go or defer statements (go foo -> go foo()).
  • Dangling selectors in go or defer statements
go foo.
y := 1

becomes

go foo._
y := 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    ThinkingToolsThis 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