A collection of methods for running functions concurrently.
go get -u github.com/eleniums/async/v2
NOTE: async/v2 is currently identical to async as of 6/12/20. When this repo was originally converted to Go Modules, it had already been tagged as v2.x.x due to previous breaking changes. At the time, there were some issues converting a repo with major version 2+ to Go Modules without the /v2 path. As such, the /v2 path was created to follow convention. Going forward, any changes will be made in the /v2 path, so only /v2 should be used.
Create some tasks to run:
foo := func() error {
// do something
return nil
}
bar := func() error {
// do something else
return nil
}Run the tasks concurrently:
errc := async.Run(foo, bar)
err := async.Wait(errc)
if err != nil {
log.Fatalf("task returned an error: %v", err)
}