gofmt: expand page to cover all flags (#23551)

This commit is contained in:
Waldir Pimenta
2026-08-12 03:45:57 +01:00
committed by GitHub
parent 7a21b5f73e
commit fa98c1f602
+17 -5
View File
@@ -5,16 +5,28 @@
- Format a file and display the result to the console:
`gofmt {{source.go}}`
`gofmt {{path/to/source.go}}`
- Format a file, overwriting the original file in-place:
`gofmt -w {{source.go}}`
`gofmt -w {{path/to/source.go}}`
- Format a file, and then simplify the code, overwriting the original file:
`gofmt -s -w {{source.go}}`
`gofmt -s -w {{path/to/source.go}}`
- Print all (including spurious) errors:
- Display diffs instead of rewriting files:
`gofmt -e {{source.go}}`
`gofmt -d {{path/to/source.go}}`
- List files that would be changed by gofmt:
`gofmt -l {{path/to/directory}}`
- Apply 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.go}}`
- Report all errors, including multiple ones per line:
`gofmt -e {{path/to/source.go}}`