Methods & pointers

Behavior hangs off the struct

A struct holds data; a method gives it behavior. Go has no classes, so a method isn't written inside the type β€” it's a plain function with a receiver: an extra parameter in parentheses before the name that says which type it belongs to.

func (w Walker) PriceLabel() string reads: "a method named PriceLabel, on Walker, that returns a string." Inside, w is the walker it was called on β€” like Swift's self, but you name it yourself (Go convention: one or two letters, usually the type's first letter).