mirror of
https://github.com/tldr-pages/tldr.git
synced 2026-08-30 17:33:50 +08:00
gofmt: expand page to cover all flags (#23551)
This commit is contained in:
+17
-5
@@ -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}}`
|
||||
|
||||
Reference in New Issue
Block a user