errgroup

package
v0.32.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	// FailFast causes the Group to cancel all goroutines immediately
	// when one goroutine returns an error.
	// FailFast must be set before any [Runner] is started.
	FailFast bool
	// contains filtered or unexported fields
}

Group allows running a number of Runner concurrently and aggregating their errors.

Using the default value of a Group is a valid use.

Its interface is inspired by the stdlib experiement errgroup: https://pkg.go.dev/golang.org/x/sync@v0.19.0/errgroup

func WithContext

func WithContext(ctx context.Context) *Group

WithContext returns a new Group.

A group instantiated this way should only live for the lifetime of the calling function as this stores the context, which can cause unintended side effects.

func (*Group) Go

func (g *Group) Go(runner Runner)

Go starts a Runner in a goroutine bound by the context.Context the Group was initialized with.

func (*Group) Wait

func (g *Group) Wait() error

Wait waits until all Runner started with Group.Go have finished and returns an aggregate of their errors.

type Runner

type Runner func(context.Context) error

Runner is a function that can be executed by a [Grouo].

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL