modern-go
Installation
SKILL.md
modern-go
Modernize Go source code by applying version-appropriate idioms, APIs, and language features. Works like go fix plus additional transformations curated from the Go team's modernize analysis passes and community best practices.
Usage
Invoke this skill when the user asks to modernize Go code. By default, modernize the entire project; the user may specify a file or directory instead.
When invoked:
- Detect the project's Go version from
go.mod(thegodirective). - Find all
.gofiles in the target scope (excludingvendor/,.git/,testdata/). - For each file, apply all transformations for versions ≤ the project's Go version, starting from the oldest to the newest.
- After all transformations, print a summary of what was changed and what was skipped.
If the user specifies a file or directory, limit the scope to that path.
Transformation Catalog
Each transformation includes a Go version gate—only apply when the project's go.mod version ≥ that version. Never apply a transformation that requires a version higher than the project declares.