What is the best way to "build" an object.
Leme write some code:
type Car struct {
Wheels int
Doors int
}
This cars are stored somewhere, somehow. So should my interface be the type of
func (s Store) GetCar() *Car
or should I make it
func (s Store) GetCar(*Car)
and pass a reference to a variable?
Im looking for some sort of rule of thumb.
Thanks!
func (s Store) GetCar(*Car)? Almost nowhere. That should answer your question. (For the nitpickers: Yes, some low-level functions expose such API to allow reduction of allocation.)