What's the most idiomatic way of initializing a Go type with many required parameters?
For example:
type Appointment struct {
Title string
Details string
Dresscode string
StartingTime int64
EndingTime int64
RSVPdate int64
Place *Place
Guests []*Guest
}
type Place struct {
Name string
Address string
}
type Guest struct {
Name string
Status string
}
I want the Appointment
type to be always valid; that is, I don't want to initialize it with a struct literal and then have to validate it.
Don't want:
a := &Appointment{
Title: "foo",
Details: "bar",
StartingTime: 12451412,
...
}
err := a.Validate()
whats the best way to initialize this type of object (with lots of fields) without having to supply all the arguments in the constructor arguments?