3 ms·
> (As a sidenote, 9 parameters for a function call can be a bit annoying in a language like Go, that doesn’t support default arguments and method overloading)
by lloeki 12y ago
> (As a sidenote, 9 parameters for a function call can be a bit annoying in a language like Go, that doesn’t support default arguments and method overloading)
This trick[0][1] turns out to be very useful.
[0] talk: https://www.youtube.com/watch?v=24lFtGHWxAQ&index=15&list=PLMW8Xq7bXrG58Qk-9QSy2HRh2WVeIrs7e https://www.youtube.com/watch?v=24lFtGHWxAQ&index=15&list=PL...
[1] slides (with transcript): http://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis http://dave.cheney.net/2014/10/17/functional-options-for-fri...
- dvirsky 12y agoI used the configuration struct pattern in this case. When you want to call ADDJOB you use an AddRequest struct, where zero values to the fields mean the parameters are not used, and the Add method accepts this struct. https://github.com/EverythingMe/go-disque/blob/master/disque/disque.go#L32 https://github.com/EverythingMe/go-disque/blob/master/disque... I want to add some builder style API for it, but didn't get to it yet.