context

package
v0.0.0-...-6b347e5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 3 Imported by: 23

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