guide
guide copied to clipboard
The Uber Go Style Guide.
Uber Go style should clarify ordering for type declarations and methods in files with multiple types
I (and several other Uber engineers) are a bit confused by the https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering section, specifically for the case where there are multiple types in one file. Should it be: ```...
2 different objects can have the same address in memory if they are empty structs (0 sized). The Go spec calls [this out](https://go.dev/ref/spec#Size_and_alignment_guarantees): > Two distinct zero-size variables may have...
This one requires some nuance but generally, for public APIs in libraries, often when a function reference is expected, an interface is preferable. Demonstration: For example, in Zap, we have...
Semi-related to [Channel Size is One or None ](https://github.com/uber-go/guide/blob/master/style.md#channel-size-is-one-or-none) We've seen cases of deadlocks/unexpected blocking caused by blocking sends to a channel (example: [tchannel-go#528](https://github.com/uber/tchannel-go/pull/528)). It's generally much safer to use...
> Channel Size is One or None Although I definitely appreciate and agree with the intent here, the rule as expressed forbids common patterns, such as the semaphore: ```go semaphore...
golangci-lint recommend change golint to revive
golint is deprecated and recommends switch to [revive](https://github.com/mgechev/revive)
This one will require some careful phrasing but the gist of the proposal is: For unexported types, it's beneficial to export fields or methods to mark them as part of...
Although we bring this up as a practice in reviews, I don't see it referenced anywhere in our style guide. We likely got this from the [Naming package contents](https://blog.golang.org/package-names#TOC_3.) section...
I still have some confusions about writing units. I hope the guide could contains some suggestions of writing tests. Maybe you could consider: 1. how to define cases? 2. should...