I don't like inversion of control, especially for simple/helper
things. For backoff I usually do something along the lines of:
for b := backoff.Exponential{}; b.Backoff(); {
whatever you want goes here
}
However, in the context of reusable Go API I would also consider
channels, because they can be involved in selects, eg:
var b backoff.Exponential
...
select {
case <-b.Backoff():
continue
case <-foo:
...
case <-bar:
...
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
golang-nuts...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.