liveBook · Manning

Formatting

As explained in Shipping Go: Develop, deliver, discuss, design, and go again

Code formatting is the automated or manual arrangement of source code according to consistent syntactic and stylistic conventions.

Formatting standardizes how source code looks and feels, giving a growing team a shared style instead of leaving every developer to make separate choices. A style guide can settle details such as tabs versus spaces, bracket placement, and spacing between functions. section 1.3.4 section 5.3

The practical goal is to remove formatting from everyday decision-making. Go provides a built-in formatter that can move brackets, replace spaces with tabs, and consolidate spacing; comparable tools include Prettier for JavaScript and autopep8 for Python. section 5.3

Make formatting part of the delivery workflow:

  • Choose a shared style and the formatter that applies it. section 5.3
  • Run the check in CI before tests so inconsistent code is rejected early. section 5.8

A formatting gate

A Makefile can define check-format as test -z $$(go fmt ./...), causing the command to pass only when formatting produces no changes. A CI format-check job can run that target before the test job, keeping style problems out of later delivery stages.

How Shipping Go: Develop, deliver, discuss, design, and go again covers it

How deep it goes
Explains style choices, formatter behavior, local automation, and CI enforcement without developing formatter internals.
Examples
Uses Go fmt commands, Makefile targets, and a CI format-check job as concrete formatting artifacts.
What it assumes
Assumes programming and repository basics while teaching shared style selection, formatter use, and automated enforcement.
What you can do after
Operate Go formatting locally and enforce unchanged formatting before tests through a CI pipeline.
How it connects
Connects formatting with coding standards, style guides, linters, code review, tests, and continuous integration.

Also explained in

Compare how 7 books explain formatting →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Shipping Go: Develop, deliver, discuss, design, and go again. The section links point to the parts of the book it draws on.