golang/go

x/tools/gopls: consider using &S form instead of *S for pointer type struct field autocompletion

Offen

#39.227 geöffnet am 23.05.2020

 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Go (19.008 Forks)batch import
NeedsDecisionToolsgoplshelp wanted

Repository-Metriken

Stars
 (133.883 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Currently autocompletion for a struct field uses the field's type as the placeholder text. For example,

type F struct {...}
type S struct {
   Field *F
}

The autocompletion for the Field will return "newText":"Field: ${1:*F},". gopls uses the type info for placeholder text, so I don't think the choice is incorrect nor invalid.

But if the suggestion used &F instead, it would be more convenient when users want to use composite literals. Especially, if the type name is long to type, reusing what's already in the placeholder will save many keystrokes.

(Based on https://github.com/golang/vscode-go/issues/85)

Contributor Guide