Canonical guidance

Use when

Avoid

Preferred pattern

g, ctx := errgroup.WithContext(ctx)

for _, id := range ids {
	g.Go(func() error {
		return fetchOne(ctx, id)
	})
}

if err := g.Wait(); err != nil {
	return err
}

Anti-pattern

Explanation: This anti-pattern is tempting because each piece seems simple, but the combination quickly becomes lifecycle glue the standard helper already solved.

Why

Related pages

Sources