I'm rather new to Go, and I really can't decide when to use a pointer vs a copy when writing struct "functions" (is that the proper term?)
type Blah struct {
c complex128
s string
f float64
}
func (b * Blah) doPtr() {
fmt.Println(b.c, b.s, b.f);
}
func (b Blah) doCopy() {
fmt.Println(b.c, b.s, b.f);
}
Now, my C++ background tells me doPtr
is more efficient in both speed and memory, however a lot of examples use doCopy
unless you're modifying the object, so am I missing something?