Greetings,

Was hoping to solicit some feedback on utilizing functional options in 
conjunction with factory methods.

I currently have the following function:

func ProcPlugin(opts …func(*procStruct){
p := defaulProc
for _, opt := range opts {
opt(&p)
}
return &p, nil
}

I am now trying to generalize things (as I will be creating more factory 
functions), and I'm trying to determine if this is the most optimal way to 
represent the logic above.

type PluginFactory func(opts ...interface{}) (Plugin, error)

func NewProcPlugin(opts ...interface{}) (Plugin, error) {
p := defaulProc
for _, opt := range opts {
opt(&p)
}
return &p, nil
}

Any feedback would be much appreciated. Please let me know if more context 
is required.

Thank you!

-- 
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