I've seen recommendations to use the following in getters and setters, i.e. pass a pointer when you are setting the value in order to change the original data, but it's not required when getting the value.
In the case of a getter, without a pointer, the value is copied. My question is, isn't it inefficient to copy the object to get value out of it, could we not use a pointer as well?
type Foo struct {
Body string
}
func (foo Foo) GetBody() interface{} {
return foo.Body
}
func (foo * Foo) SetBody(body string) {
foo.Body = body
}