https://github.com/hbagdi/gang
A library to manage goroutines with the same lifetime
https://github.com/hbagdi/gang
Last synced: 4 months ago
JSON representation
A library to manage goroutines with the same lifetime
- Host: GitHub
- URL: https://github.com/hbagdi/gang
- Owner: hbagdi
- License: apache-2.0
- Created: 2020-05-18T04:08:24.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-19T03:05:44.000Z (about 5 years ago)
- Last Synced: 2025-01-06T18:21:40.671Z (5 months ago)
- Language: Go
- Homepage: https://godoc.org/github.com/hbagdi/gang
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# gang
[](https://github.com/hbagdi/gang/actions?query=branch%3Amaster+event%3Apush)
[](https://godoc.org/github.com/hbagdi/gang)Package gang provides utilities to manage multiple goroutines.
## Synopsis
```go
package mainimport (
"context"
"fmt""github.com/hbagdi/gang"
)func main() {
// zero value is usable out of the box
var g gang.Gang// add multiple functions which should be executed concurrently
g.AddWithCtxE(func(ctx context.Context) error {
fmt.Println("foo")
return fmt.Errorf("err1")
})
g.AddWithChanE(func(done <-chan struct{}) error {
fmt.Println("bar")
return fmt.Errorf("err2")
})// start execution of all the functions
errCh := g.Run(context.Background())// collect errors from all the functions
for err := range errCh {
fmt.Println(err)
}
// execution finishes when errCh is closed
}
```## Changelog
Changelog can be found in the [CHANGELOG.md](CHANGELOG.md) file.
## License
gang is licensed with Apache License Version 2.0.
Please read the [LICENSE](LICENSE) file for more details.