liveBook · Manning

Errgroup.Group

errgroup.Group is a Go type that coordinates concurrent functions, waits for them to finish, and records the first non-nil error.

How 2 Manning books explain it

Learn Go with Pocket-Sized Projects

errgroup.Group is a Go synchronization type that coordinates goroutines and reports an error from a failed goroutine.

How it is used
Coordinates concurrent goroutines when at least one goroutine’s error needs handling.
How deep it goes
Explains group creation, concurrency limits, goroutine registration, waiting, and returned errors through a runnable example.
Examples
Uses concurrent rice and curry preparation, including a task that may return an error.
What you can do after
Apply it via golang.org/x/sync/errgroup to limit parallel work and handle a goroutine error at a synchronization point.

Read how Learn Go with Pocket-Sized Projects explains errgroup.Group →

100 Go Mistakes and How to Avoid Them

errgroup.Group is a type that coordinates a group of goroutines and records the first non-nil error returned by them.

How it is used
Coordinates parallel calls while propagating the first error and sharing cancellation through context.
How deep it goes
Defines WithContext, Go, and Wait and demonstrates an indexed results handler, without detailing package internals.
Examples
Uses parallel foo calls over circles, an indexed results slice, and a corrected errgroup handler.
What you can do after
Build it from scratch using WithContext, Go, and Wait to collect results and return the first error.

Read how 100 Go Mistakes and How to Avoid Them explains errgroup.Group →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.