LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

go-fix

update Go code for newer API versions

TLDR

Fix all packages in the current module
$ go fix ./...
copy
Fix a specific package
$ go fix [package]
copy
Preview changes as a unified diff without modifying files
$ go fix -diff [package]
copy
Output fixes as JSON instead of applying them
$ go fix -json [package]
copy
Use a custom fix tool
$ go fix -fixtool=[prog] [package]
copy

SYNOPSIS

go fix [-diff] [-json] [-fixtool=prog] [packages]

DESCRIPTION

go fix updates Go code for newer Go versions. It applies transformations for API changes and deprecated patterns, helping maintain code across Go releases.The tool runs specific fixers (analyzers) that handle known changes between Go versions. As of Go 1.24, go fix uses the same analysis framework as go vet and supports selecting specific analyzers by name.Available analyzers include fixes for: replacing interface{} with any, using min/max builtins, modernizing string operations, updating fmt.Appendf patterns, range-over-int, and more.Files are modified in place by default, so version control is recommended before running.

PARAMETERS

PACKAGES

Packages to fix. Use ./... for all packages in the current module.
-diff
Print changes as a unified diff instead of applying them. Useful for CI pipelines.
-json
Emit fixes as JSON output instead of applying them.
-fixtool prog
Select a different analysis tool with alternative or additional fixers. The default is go tool fix.
-v
Verbose output.
-n
Print the commands that would be executed but do not run them.
-x
Print the commands as they are executed.

CAVEATS

Modifies files in place unless -diff is used. Use version control. May need manual review. Limited to known fixes. Each run analyzes only one build configuration; run with different GOARCH/GOOS values for multi-platform projects.

HISTORY

go fix is part of the Go toolchain. Originally introduced for handling breaking API changes during Go 1.x development, it was significantly enhanced in Go 1.24 to use the analysis framework, gaining support for custom analyzers and modernization fixes.

SEE ALSO

go(1), go-vet(1), go-fmt(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid