3 ms·
Higher order functions are super useful for middleware in Go. Functions are also nillable which makes them useful as options. Combined with variatic functions y
by kodah 4y ago
Higher order functions are super useful for middleware in Go. Functions are also nillable which makes them useful as options. Combined with variatic functions you can build quite a nice API.
- cookiengineer 4y agoDoes that mean you use variadic functions to adapt to different structs and their properties/fields and they all return the same "base struct"? Do you have example code? I am now really curious, but don't know what to google.
- gouggoug 4y agoI think you are looking for “functional options”[0] [0] https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis https://dave.cheney.net/2014/10/17/functional-options-for-fr...
- bryancoxwell 4y agoOh dear I love that. Thanks for sharing.