ctxgroup

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

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 similar to errgroup.Group. The main difference is Group.Go accepts a function with a context.Context as its first argument.

It's zero value is valid, it contains context.Background as its internal context and does not cancel on error.

func New

func New(ctx context.Context) *Group

New returns a new Group with ctx as its internal context, which is passed to the function(s) passed to Group.Go. The context is not canceled when a function passed to Group.Go returns an error.

func (*Group) Go

func (g *Group) Go(fn func(ctx context.Context) error)

Go calls the given function in a new goroutine. The Group's internal context is passed as argument to the function. Errors from all calls are collected, combined and returned by Group.Wait.

func (*Group) Wait

func (g *Group) Wait() error

Wait blocks until all function calls from the Group.Go method have returned, then returns all collected errors as a (multi) error.

Jump to

Keyboard shortcuts

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