Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: provide quickfix for composite literals with unkeyed fields #53062

Closed
hyangah opened this issue May 25, 2022 · 4 comments
Closed
Assignees
Labels
FeatureRequest FrozenDueToAge gopls/analysis Issues related to running analysis in gopls gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented May 25, 2022

gopls provides diagnostics about composite literals with unkeyed fields.
It will be convenient if the diagnostic is accompanied with the quickfix.

Screen Shot 2022-05-24 at 8 22 58 PM

@hyangah hyangah added FeatureRequest gopls/analysis Issues related to running analysis in gopls labels May 25, 2022
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels May 25, 2022
@gopherbot gopherbot added this to the Unreleased milestone May 25, 2022
@hyangah hyangah modified the milestones: Unreleased, gopls/later May 26, 2022
@hyangah
Copy link
Contributor Author

hyangah commented May 26, 2022

@suzmue @jamalc Can you take a look if this can be implemented while investigating on a related feature (inLayHints)?

@findleyr findleyr added the Refactoring Issues related to refactoring tools label May 26, 2022
@findleyr
Copy link
Contributor

I think this can be an inLayHint suggestion (by providing InlayHint textedits), but it would be good to have available as a quickfix as well.

@gopherbot
Copy link

Change https://go.dev/cl/414674 mentions this issue: go/analysis: add suggested fix for unkeyed composite literals

gopherbot pushed a commit to golang/tools that referenced this issue Jun 30, 2022
Include a suggested fix with the diagnostic for unkeyed composite
literals. This suggested fix will add the name of each of the
fields.

For golang/go#53062

Change-Id: I0c33191ff3cf66c95a9a055848274cc2b0c38224
Reviewed-on: https://go-review.googlesource.com/c/tools/+/414674
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
@findleyr findleyr modified the milestones: gopls/later, gopls/v0.9.0 Jun 30, 2022
@suzmue
Copy link
Contributor

suzmue commented Jun 30, 2022

Release

A quick fix was added to add field names to struct literals with unkeyed fields.

addfieldnames

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge gopls/analysis Issues related to running analysis in gopls gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants