Uber is a technology company based in Silicon Valley, USA, and an early adopter of the Go language. It has open-sourced many golang projects, such as the well-known zap and jaeger in the Gopher community. At the end of 2018, Uber open-sourced its internal Go style guide on GitHub. After a year of accumulation and updates, the guide has taken shape and received extensive attention from Gophers. This article is the Chinese version of the guide.

Code style governs the conventions that control our code. These conventions cover not only the source file format handled by gofmt for us.

The purpose of this guide is to manage this complexity by describing in detail the considerations for writing Go code at Uber. The existence of these rules is to make the codebase easy to manage while still allowing engineers to use Go language features more effectively.

The guide was initially written by Prashant Varanasi and Simon Newton with the aim of enabling colleagues to quickly use Go. Over the years, the guide has been modified based on feedback from others.

This document records the idiomatic conventions in Go code that we follow at Uber. Many of these are general guidelines for Go, while other extended guidelines depend on the following external guides:

  1. Effective Go
  2. Go Common Mistakes
  3. Go Code Review Comments

Our goal is to make the code examples suitable for use with two Go releases releases.

All code should pass the checks of golint and go vet without errors. We recommend setting your editor to:

  • Run goimports on save
  • Run golint and go vet for error checking

GitHub repository: https://github.com/uber-go/guide

GitHub repository: https://github.com/xxjwxc/uber_go_guide_cn