snippetbashTip
gofmt — Format Go source code. More information: <https://pkg.go.dev/cmd/gofmt>.
Viewed 0 times
commandformatsourceclicodeinformationgofmtmore
Problem
How to use the
gofmt command: Format Go source code. More information: <https://pkg.go.dev/cmd/gofmt>.Solution
gofmt — Format Go source code. More information: <https://pkg.go.dev/cmd/gofmt>.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}}Code Snippets
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}}Context
tldr-pages: common/gofmt
Revisions (0)
No revisions yet.