I have 33 callback functions:
func Cb1() {} func Cb2() {} func Cb3() {} func Cb4() {} func Cb5() {} // other 28 callbacks ... All of them should be passed into one function. So, I did it in the most obvious way:
type fn func() func My(Cb1 fn, Cb2 fn, Cb4 fn, Cb3 fn, Cb5 fn, ... and so on ...){ Cb1() Cb2() Cb4() Cb5() } My(Cb1, Cb2, Cb4, Cb3, Cb5, ... and so on ...) I'm sure I'm not the only one with sore eyes from the sight of this "train" of arguments.
In javascript I would just wrap them all up in a class/object and pass them as a single argument, like so:
function My(cb = {}){ cb.Cb1(); cb.Cb2(); cb.Cb4(); cb.Cb5(); } My({ Cb1, Cb2, Cb4, Cb5 }); But how do we do this in Go?
function My(cb...func()) {}