The builder pattern generally isn't needed in go, because go has flexible 
struct literals where you can omit any members you don't want. 

You can implement it if you like, but it just adds a layer of boilerplate:
https://gist.github.com/vaskoz/10073335

Some people are drawn to functional options instead:
https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
https://www.calhoun.io/using-functional-options-instead-of-method-chaining-in-go/

But if you look at the standard library as a source of inspiration and good 
practice, complex configuration is typically done via structs.  See for 
example http.Server <https://golang.org/pkg/net/http/#Server>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/39e38cd7-93ee-4084-89e4-a22bcd1baaa6n%40googlegroups.com.

Reply via email to