This question already has an answer here:
Is there a good reason for returning pointers on the "constructor" of a struct? For example:
type MyType struct{}
func NewMyType() *MyType {
var m *MyType
return m
}
vs.
type MyType struct{}
func NewMyType() MyType {
var m MyType
return m
}
In most cases, the "constructors" accept some arguments and return a pointer to a type. Why not just return a value?
Thanks in advance.
</div>