errgroup

package
v2.1.59 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrGroup

type ErrGroup interface {
	// Go calls the given function in a new goroutine.
	//
	// The first call to return a non-nil error cancels the group; its error will be
	// returned by Wait.
	Go(fn func(ctx context.Context) error)

	// GOMAXPROCS set max goroutine to work.
	GOMAXPROCS(n int)

	// Wait blocks until all function calls from the Go method have returned, then
	// returns the first non-nil error (if any) from them.
	Wait() error
}

A ErrGroup is a collection of goroutines working on subtasks that are part of the same overall task.

A zero Group is valid, has no limit on the number of active goroutines, and does not cancel on error. use WithContext instead.

func WithContext

func WithContext(ctx context.Context) ErrGroup

WithContext returns a new group with a canceled Context derived from ctx.

The derived Context is canceled the first time a function passed to Go returns a non-nil error or the first time Wait returns, whichever occurs first.

Jump to

Keyboard shortcuts

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