errgroup

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errgroup provides synchronization, error propagation and context cancellation for groups of goroutines working on subtasks of a common task, mirroring the WithContext, Go and Wait subset of the golang.org/x/sync/errgroup API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group is a collection of goroutines working on subtasks of a common task. The zero value is valid and does not cancel a context on error. A Group must not be reused for different tasks.

func WithContext

func WithContext(ctx context.Context) (*Group, context.Context)

WithContext returns a new Group and an associated 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; the error is available via context.Cause.

func (*Group) Go

func (group *Group) Go(function func() error)

Go calls the given function in a new goroutine. The first call to return a non-nil error cancels the group's context, if the group was created by calling WithContext; its error will be returned by Wait.

func (*Group) Wait

func (group *Group) Wait() error

Wait blocks until all function calls from the Go method have returned, then returns the first non-nil error (if any) from them. It cancels the group's context, if the group was created by calling WithContext.

Jump to

Keyboard shortcuts

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