EDIT: Please see the attached stack overflow issue. It describes exactly what I am trying to get across and then some :)
With reference to the below code, is it better/standardized/convention to return the address of the variable, or create the variable with an address? I know that either way you are modifying the same structure, but I want to know which way is cleaner? I also would like to know if there are any pros / cons to either way of doing it.
type Thing struct {
}
func getThing() *Thing {
thing := Thing{}
// modify thing here
return &thing //return the address to the thing here
}
OR
type Thing struct {
}
func getThing() *Thing {
thing := &Thing{} //create the address to the thing here
//modify thing here
return thing
}
OR
type Thing struct {
}
func getThing() *Thing {
thing := new(Thing)
//modify thing here
return thing
}