Functional Options
type Porsche struct {
Model string
Trim string
Color string
Wheels string
}type Option func(*Porsche)
func Model(val string) Option {
return func(p *Porsche) {
p.Model = val
}
}
func Trim(val string) Option {
return func(p *Porsche) {
p.Trim = val
}
}
func Color(val string) Option {
return func(p *Porsche) {
p.Color = val
}
}
func Wheels(val string) Option {
return func(p *Porsche) {
p.Wheels = val
}
}Last updated