You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The style guide is nicely written, and (afaict) unambiguous. However, it can be a bit hard to piece together the entire picture just from reading rules (even with examples). In particular, I found the function grouping and ordering section hard to grok: https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering
Proposal: let's add a "kitchen sink" example file containing a large subset of the style guide's rules, with comments. I think this would be most helpful to elucidate the "file structure" rules, e.g. ordering of types, variables, methods, etc.
A brief example:
package example
// Consts go at the top (reference here)
const (
)
// Next vars (reference here)
var (
)
// Next type defs
type Foo struct{
}
type Bar struct{
}
func NewFoo() *Foo {
return &Foo{}
}
// Group methods by receiver
func (f *Foo) DoFooThing() {
// maybe throw in some examples r.e. early return etc here.
}
func (b *Bar) DoBarThing() {
}
// Freestanding functions are last. https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering
func helper()
The text was updated successfully, but these errors were encountered:
The style guide is nicely written, and (afaict) unambiguous. However, it can be a bit hard to piece together the entire picture just from reading rules (even with examples). In particular, I found the function grouping and ordering section hard to grok: https://github.com/uber-go/guide/blob/master/style.md#function-grouping-and-ordering
Proposal: let's add a "kitchen sink" example file containing a large subset of the style guide's rules, with comments. I think this would be most helpful to elucidate the "file structure" rules, e.g. ordering of types, variables, methods, etc.
A brief example:
The text was updated successfully, but these errors were encountered: