Help us shape the future of Go! Take the 2026 Go Developer Survey

bg

package
v0.40.22 Latest Latest
Warning

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

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

Documentation

Overview

Package bg tracks the process's fire-and-forget goroutines (a re-auth email, a close hook's push, a detached write) so shutdown can wait for them, bounded, instead of closing the database under them.

Index

Constants

This section is empty.

Variables

View Source
var Default = &Group{}

Default is the process-wide group; main waits on it at shutdown.

Functions

func Go

func Go(f func())

Go runs f on the Default group.

Types

type Group

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

Group counts running goroutines. It is a counter under a mutex rather than a sync.WaitGroup because a hook can start new work while shutdown is already waiting, and WaitGroup panics on an Add that races a Wait at zero.

func (*Group) Go

func (g *Group) Go(f func())

Go runs f in a goroutine the group waits for. Safe to call while Wait runs: the new goroutine is tracked too.

func (*Group) Wait

func (g *Group) Wait(timeout time.Duration) bool

Wait blocks until no goroutine started with Go is running, or timeout passes. It reports whether the group went idle.

Jump to

Keyboard shortcuts

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