Go Async Group can be more easily manage goroutine.
errgroup has the goal is to cancel all asynchronous when at least one async fails.
This package is used to wait until all the executed asynchronous processing is finished.
func main() {
var ag async.Group
var sum, expected uint32
for i := 0; i < times; i++ {
expected++
ag.Go(func() {
atomic.AddUint32(&sum, 1)
})
}
ag.Wait()
fmt.Println(sum, expected)
}
If you want to use at your application, see example.
go get -u github.com/Code-Hex/go-async
- Fork https://github.com/Code-Hex/go-async/fork
- Commit your changes
- Create a new Pull Request
I'm waiting for a lot of PR.