Use a pointer receiver (*T) when the method must modify the receiver's fields or when the receiver is large to avoid copying; use a value receiver (T) for small, immutable types or when modification is not needed. In Go, if a type has both pointer and value receivers, you can call either method on either a pointer or a value, but the compiler will automatically take the address of a value if a pointer receiver is required.
// Modifies the receiver: requires pointer receiver
func (z *Int) SetInt64(x int64) *Int {
z.doinit()
C.mpz_set_si(&z.i[0], C.long(x))
return z
}
// Reads the receiver: value receiver is sufficient for small types
func (z Int) Len() int {
z.doinit()
return int(C.mpz_sizeinbase(&z.i[0], 2))
}