3 ms·
Agreed. It's not as 'traditional Go' but I find there is way less interface boilerplate if you just pass functions around. ie instead of ``` type ThingDoer i
by ukoki 2y ago
Agreed. It's not as 'traditional Go' but I find there is way less interface boilerplate if you just pass functions around.
ie instead of
```
type ThingDoer interface {
DoThing()
}
func someFunction(thingDoer ThingDoer) {
ThingDoer.doThing()
}
```
just have
```
func someFunction(doThing func()) {
doThing()
}
```
Then when testing you can just pass a test implementation of the 'doThing' function that just verifies it was called with the expected arguments.