Notes

Go Receiver Pointers vs. Values

September 4, 2017

When writing a method in Go, should you use a pointer or a value receiver?

Type Use
Basic Value
Map Value
Func Value
Chan Value
Slice (no reslicing/reallocating) Value
Small Struct/Array Value
Concurrent mutations Value if possible
Is Mutated By Method Pointer
Large Struct/Array Pointer
Contains a sync.Mutex Pointer
Contains Pointers Pointer
🤷 Pointer

Distilled from Golang Code Review Comments