2017-12-02 08:26:20 +00:00
|
|
|
# gofmt
|
|
|
|
|
2024-02-14 20:25:13 +00:00
|
|
|
> Format Go source code.
|
2019-06-03 01:06:36 +01:00
|
|
|
> More information: <https://golang.org/cmd/gofmt/>.
|
2017-12-02 08:26:20 +00:00
|
|
|
|
|
|
|
- Format a file and display the result to the console:
|
|
|
|
|
|
|
|
`gofmt {{source.go}}`
|
|
|
|
|
|
|
|
- Format a file, overwriting the original file in-place:
|
|
|
|
|
|
|
|
`gofmt -w {{source.go}}`
|
|
|
|
|
|
|
|
- Format a file, and then simplify the code, overwriting the original file:
|
|
|
|
|
|
|
|
`gofmt -s -w {{source.go}}`
|
|
|
|
|
|
|
|
- Print all (including spurious) errors:
|
|
|
|
|
|
|
|
`gofmt -e {{source.go}}`
|