Go lets you attach functions to types. These are called methods. Here's a quick preview:
type Rectangle struct {
Width, Height int
}
func (r Rectangle) Area() int {
return r.Width * r.Height
}
The (r Rectangle) before the function name is the receiver. It attaches this function to the Rectangle type. You'll learn methods in detail in a later section.