Go fmt: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=External= * https://pkg.go.dev/cmd/gofmt =Internal= * go Tool * Go Source Code Formatting =Overview= The <code>fmt</code> ("format") command formats source code files, by applying a predetermined layout to Go source code. It delegates to <code>gofmt</code>, and it is equivalent to: <syntaxhighlight lang='bash'> gofmt -l -w <file> </syntaxhighlight> One counterintuitive fact is that it uses the tab charac...") |
|||
Line 7: | Line 7: | ||
=Overview= | =Overview= | ||
The <code>fmt</code> ("format") command formats source code files, by applying a predetermined layout to Go source code. | The <code>fmt</code> ("format") command formats source code files, by applying a predetermined layout to Go source code. | ||
<code>go fmt</code> delegates to <code>gofmt</code>, and it is equivalent to: | |||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> |
Revision as of 23:14, 2 July 2024
External
Internal
Overview
The fmt
("format") command formats source code files, by applying a predetermined layout to Go source code.
go fmt
delegates to gofmt
, and it is equivalent to:
gofmt -l -w <file>
One counterintuitive fact is that it uses the tab character for indentation. This is uncommon.
Rob Pike: "gofmt style is no one's favorite, yet gofmt is everyone's favorite".