Skip to content

x/tools/gopls: struct completions #76626

@diogox

Description

@diogox

gopls version

golang.org/x/tools/gopls v0.20.0

go env

N/A

What did you do?

In Zed, with gopls enabled, I type:

type Demo struct {
  Field1
}

func main() {
  d := De[...]
}

Where [...] is where my cursor is.

What did you see happen?

gopls suggests Demo as a completion.

What did you expect to see?

gopls knows d := Demo is not valid, as it rightly complains with Demo (type) is not an expression (compiler NotAnExpr).

Therefore, I would expect it to suggest Demo{} as the only valid completion for this instance.

Other possible scenarios where Demo might be valid, such as d := make(chan Demo) are clearly not applicable at the point of completion.

Editor and settings

No response

Logs

No response

Metadata

Metadata

Assignees

Labels

FeatureRequestIssues asking for a new feature that does not need a proposal.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