Code Guide

About

This documentation codifies the current decisions for writing readable and idiomatic Go. Adherence to the Code Guide is not intended to be absolute, and these documents will never be exhaustive. Our intention is to minimize the cognitive load required for writing readable Go so that new team members can avoid common mistakes.

The Code Guide also serves to unify the style guidance given by anyone reviewing Go code at Swoop, and should capable of being understood by anyone with sufficient experience in Go.

This documentation is intend to:

This documentation is not intend to:

Regarding style, there will always be differences of opinion from one Go programmer to another and from one team’s codebase to another. However, it is in the best interest of Swoop that our codebase be as consistent as possible. To that end, feel free to make style improvements as you see fit, but you do not need to nit-pick every violation of the Style Guide that you find.

In particular, these documents may change over time, and that is no reason to cause extra noise in existing codebases; it suffices to write new code using the latest style guide and address nearby issues over time.

Remember that none of these decisions, or the people making them, are infallible; they’re just our best attempts at the time we made them, not wisdom received on stone tablets. If someone asks why do we do X instead of Y, please try to present the engineering reasons fairly, including for Y, and avoid argument solely by appeal to authority. It’s too easy to fall into the “well that’s just not how it’s done here” trap.

Definitions

The following words, which are used throughout the Style Guide, are defined below:

Additional References