Non-decisions
source ↗Non-decisions
A style guide cannot enumerate positive prescriptions for all matters, nor can it enumerate all matters about which it does not offer an opinion. That said, here are a few things where the readability community has previously debated and has not achieved consensus about.
- Local variable initialization with zero value.
var i intandi := 0are equivalent. See also initialization best practices. - Empty composite literal vs.
newormake.&File{}andnew(File)are equivalent. So aremap[string]bool{}andmake(map[string]bool). See also composite declaration best practices. - got, want argument ordering in cmp.Diff calls. Be locally consistent, and include a legend in your failure message.
errors.Newvsfmt.Errorfon non-formatted strings.errors.New("foo")andfmt.Errorf("foo")may be used interchangeably.
If there are special circumstances where they come up again, the readability mentor might make an optional comment, but in general the author is free to pick the style they prefer in the given situation.
Naturally, if anything not covered by the style guide does need more discussion, authors are welcome to ask – either in the specific review, or on internal message boards.