Introduction
Styles are the conventions that govern our code. The term style is a bit of amisnomer, since these conventions cover far more than just source fileformatting—gofmt handles that for us.
The goal of this guide is to manage this complexity by describing in detail theDos and Don'ts of writing Go code at Uber. These rules exist to keep the codebase manageable while still allowing engineers to use Go language featuresproductively.
This guide was originally created by Prashant Varanasi and Simon Newton asa way to bring some colleagues up to speed with using Go. Over the years it hasbeen amended based on feedback from others.
This documents idiomatic conventions in Go code that we follow at Uber. A lotof these are general guidelines for Go, while others extend upon externalresources:
- Effective Go
The Go common mistakes guideAll code should be error-free when run through
golint
andgo vet
. Werecommend setting up your editor to:Run
goimports
on save- Run
golint
andgo vet
to check for errorsYou can find information in editor support for Go tools here:https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins