context

package
v0.0.0-...-1bd86d9 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 4 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithValue

func WithValue(parent context.Context, key any, val any) context.Context

WithValue seem as context.WithValue but without key type comparable check, and be 20x faster

Types

type Context

type Context[T any] interface {
	Inject(ctx context.Context, value T) context.Context
	From(ctx context.Context) T
	MayFrom(ctx context.Context) (T, bool)
}

func New

func New[T any](optFns ...OptionFunc[T]) Context[T]

type OptionFunc

type OptionFunc[T any] func(c *ctx[T])

func WithDefaults

func WithDefaults[T any](v T) OptionFunc[T]

func WithDefaultsFunc

func WithDefaultsFunc[T any](defaultsFunc func() T) OptionFunc[T]

Jump to

Keyboard shortcuts

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