A Go library for managing concurrent execution with a goroutine pool. Control concurrency, limit goroutines, and keep your code simple.
Add to your Go project:
go get github.com/gohacks/parallel
Running too many goroutines at once can exhaust resources. Parallel gives you a simple pool with a configurable concurrency limit — add tasks, and the library manages the rest.
New(), Run(), Wait(). That's it.
parallel.Errors().
Add to your Go module:
go get github.com/gohacks/parallel
pool := parallel.New(context.Background(), 3, false)
for i := 1; i <= 10; i++ {
pool.Run(func() { yourFunction(yourParams) })
}
pool.Wait()
| Function | Description |
|---|---|
New(ctx, max, cancelOnError) |
Creates a pool with max concurrent goroutines |
pool.Run(task) |
Adds a task to the pool |
pool.Wait() |
Waits for all tasks to complete |
parallel.Errors() |
Returns errors collected from tasks |