gofmt
Format Go source code. tldr-pages
On several platforms
Several platforms
Format a file and display the result to the console
gofmt path/to/source.goIdentifyFormat a file, overwriting the original file in-place
gofmt -w path/to/source.goIdentifyFormat a file, and then simplify the code, overwriting the original file
gofmt -s -w path/to/source.goIdentifyDisplay diffs instead of rewriting files
gofmt -d path/to/source.goIdentifyList files that would be changed by gofmt
gofmt -l path/to/directoryIdentifyApply a rewrite rule to the source before reformatting (e.g. replace nil checks with isNil calls)
gofmt -r 'x == nil -> isNil(x)' path/to/source.goIdentifyReport all errors, including multiple ones per line
gofmt -e path/to/source.goIdentify