The variadic pattern is pretty good imo, but it does permit the caller to pass 
more than 1 value which implies you need to decide on the bahviour (first value 
wins, last value wins,etc ...), the document and add tests for the possible 
states. 

Iff there is only one possible option and it's only used infrequently, I'd be 
inclined to try something like this

// Foo returns a new Bar
func Foo() Bar

// FooWithQuxx returns a new Bar using the underlying Quxx
func FooWithQuxx(q Quxx) Bar

Internally both methods dispatch to a private foo(q Quxx) Bar, but that's 
unimportant. 

If you find that your going to have more than one non default constructor, 
switching to functional options may prove more extensible as the API grows. 

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to