package a
type Foo struct { // want `the methods of "Foo" use different receiver names: f, fo.`
Name string
}
func (f Foo) A() {}
func (fo Foo) B() {}
type Bar struct{} // want `the methods of "Bar" use pointer receiver and non pointer receiver.`
func (b Bar) A() {}
func (b *Bar) B() {}
type Fuu struct{}
func (faaa Fuu) A() {} // want `the receiver name "faaa" is too long.`
Be consistent, too: if you call the receiver “c” in one method, don’t call it “cl” in another.
The name of a method’s receiver should be a reflection of its identity; often a one or two letter abbreviation of its type suffices (such as “c” or “cl” for “Client”).
type Config struct {
// MaxNameLength maximum length for a receiver name. MaxNameLength int// TypeConsistency allows to use pointer receiver and non-pointer receiver on the same struct. TypeConsistency bool
}