Skip to content

proposal: cmd/fix: apply modernizers #71859

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

Open
jba opened this issue Feb 20, 2025 · 2 comments
Open

proposal: cmd/fix: apply modernizers #71859

jba opened this issue Feb 20, 2025 · 2 comments
Assignees
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) Proposal Refactoring Issues related to refactoring tools ToolProposal Issues describing a requested change to a Go tool or command-line program.
Milestone

Comments

@jba
Copy link
Contributor

jba commented Feb 20, 2025

Proposal Details

go fix should have a type of fix called modernize that applies modernizers.

As an example, running go fix would change all occurrences of interface{} to any, provided the identifier any is not shadowed.

For the current set of modernizers, see https://go.googlesource.com/tools/+/refs/heads/master/gopls/internal/analysis/modernize.

@jba jba added the Proposal label Feb 20, 2025
@jba jba assigned jba and adonovan Feb 20, 2025
@gopherbot gopherbot added this to the Proposal milestone Feb 20, 2025
@gabyhelp gabyhelp added the ToolProposal Issues describing a requested change to a Go tool or command-line program. label Feb 20, 2025
@adonovan adonovan added Analysis Issues related to static analysis (vet, x/tools/go/analysis) Refactoring Issues related to refactoring tools labels Feb 20, 2025
@ianlancetaylor ianlancetaylor moved this to Incoming in Proposals Feb 26, 2025
@adonovan
Copy link
Member

adonovan commented Apr 21, 2025

Currently the go fix comment command is completely unrelated to the //go:fix inline annotation; it's just a grab-bag of syntax-only rewrites for very ancient features. I'm not sure whether anyone really uses it at all. At some point it might be worth rethinking it as a front-end for the go/analysis framework and the multichecker's -fix functionality.

@mvdan
Copy link
Member

mvdan commented Apr 21, 2025

(I assume you meant "go fix command" above). I have yet to encounter a recent Go user (say, who started using Go after 2015 or so) who is aware of go fix or what it does. I suspect at this point the command could be redesigned to do whatever you feel like is most useful, as long as it can be safely run on large codebases without having to worry about any subtle breakages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) Proposal Refactoring Issues related to refactoring tools ToolProposal Issues describing a requested change to a Go tool or command-line program.
Projects
Status: Incoming
Development

No branches or pull requests

5 participants