Go fmt: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 8: Line 8:
=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. The program


<code>go fmt</code> delegates to <code>gofmt</code>, and it is equivalent to:
<code>go fmt</code> delegates to <code>gofmt</code>, and it is equivalent to:

Revision as of 23:20, 2 July 2024

External

Internal

Overview

The fmt ("format") command formats source code files, by applying a predetermined layout to Go source code. The program

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".