Go fmt: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 4: Line 4:
* [[Go_Tool#fmt_(gofmt)|go Tool]]
* [[Go_Tool#fmt_(gofmt)|go Tool]]
* [[Go_Language#Source_Code_Formatting|Go Source Code Formatting]]
* [[Go_Language#Source_Code_Formatting|Go Source Code Formatting]]
* [[Go_Style#Overview|Go Style]]


=Overview=
=Overview=

Revision as of 23:16, 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".