Some notes on Receivers
GoLangReview of receivers
When a value receiver is defined, Go automatically generates a corresponding pointer receiver.
Auto-generating a pointer receiver causes differences in the method sets of pointer types and value types.
For example, take the Len()
method below, Go will automatically generate a corresponding pointer receiver version:
type List []int
func (l List) Len() int { return len(l) }
// func (l *List) Len() int { ... }
func (l *List) Append(val int) { *l = append(*l, val) }
For type List
, its method set includes: