context

package
v0.0.0-...-d4750d2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDetached

func NewDetached(parent context.Context) context.Context

NewDetached returns a new context with the same values as the parent. This can be used to clone a context without inheriting the cancellation properities of the parent, meaning if the parent is cancelled, the child is not. Likewise, the child context does not cancel the parent. This can be useful when performing operations asyncronously.

Note that this goes against the designed behaviour of Go contexts and therefore this function should be used with caution. See similar: https://github.com/golang/tools/blob/master/internal/xcontext/xcontext.go

func NewDetachedWithTimeout

func NewDetachedWithTimeout(
	parent context.Context, dur time.Duration,
) (context.Context, context.CancelFunc)

NewDetachedWithTimeout returns a new detached child context that cancels after the provided duration. It is not cancelled by the parent context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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