Thanks for the suggestion. I like the idea of having an options struct with default values. What I don’t understand is why I’d take multiple functions to alter the defaults, e.g. options ...func(*BarOptions)
instead of just having a new function like NewBarOptions
that returns the defaults and push the responsibility to the user to adapt it before calling NewBar
.
This would look like
func main() {
_ = NewBar(2, true)
o := NewBarOptions()
o.Logger = Logger{}
_ = NewBar(2, true, o)
}