Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: