taker provides simple, modular functions for working with asynchronous Golang code.
Do you often find yourself writing repetitive error handling checks in Go?
if err := wakeUp(); err != nil {
return err
}
if err := boilWater(); err != nil {
return err
}
if err := makeSandwich(); err != nil {
return err
}
if err := brushTeeth(); err != nil {
return err
}
Doesn't this kind of code just make you want to use promises, try
/ catch
or something like async
?
Fear no more! taker allows you to get rid of the redundant error handling by providing a set of common utility functions used for dealing with asynchronous code.
In the above example, we could wrap our imperative functions into smaller tasks
and chain them using Series
(each of the above functions would return a
task):
return taker.Series(
taker.Wrap(wakeUp),
taker.Wrap(boilWater),
taker.Wrap(makeSandwich),
taker.Wrap(brushTeeth),
)
taker is based on the idea of "tasks". A task has to implement a Run() error
method. Instead of implementing our own tasks, we can also wrap preexisting, functions into tasks using taker.Wrap(myFunc)
where myFunc
implements func() error
.
For detailed docs, see Godocs.
Using go get
:
$ go get github.com/alexanderGugel/taker
taker currently uses govendor for vendoring dependencies.