Factories
- Remember: No constructors in Go.
Instead we use the design pattern: Factory
func NewPerson(name string, age int) Person {
return Person{name, age}
}
With some clever naming, we could name a package
person
and the functionNew
to make it look like a constructor, i.e.person.New("John", 30)
.