Format Go Programs With Go Fmt

Continuing my Go adventures, I must document one of my favourite parts.

How much time do you spend tidying up, styling and aligning your code? Probably more than zero.

Go takes the approach that the machine can handle formatting, and it’s better if programmers don’t have to adapt to different formatting styles.

Simply run:

go fmt file/path

and your Go code will be automatically formatted to the canonical Go style.

Cool aye? Read more on the gofmt docs.