11.7 Choosing Between Value and Pointer Receivers: The Rules
Alright, let’s cut through the noise. Choosing between value and pointer receivers isn’t about memorizing a list of rules; it’s about understanding what you’re telling the compiler to do. Get this right, and your code is efficient and predictable. Get it wrong, and you’ll have a delightful time chasing bugs that make no sense. My favorite. The core principle is embarrassingly simple: do you need to modify the receiver’s state? If yes, use a pointer (*T). If no, you probably want a value (T). But of course, it’s never that simple, is it? We have to talk about efficiency, method sets, and the dreaded implicit indirection.