Choosing a value or pointer receiver
So when do you use a pointer receiver vs a value receiver? Two good reasons to reach for a pointer:
- You need to modify the receiver.
- You want to avoid copying a large struct on every call.
In this example, Abs doesn’t actually need to modify anything — but it still uses *Vertex to stay consistent with Scale.
That’s the rule: pick one style for all methods on a type. Don’t mix value and pointer receivers on the same type. It causes confusion — and problems with interfaces, which you’ll see soon.