contextdi

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyDebugMode string = "_DI_FLG_DEBUG"
)

Variables

View Source
var (
	ErrKeyNotFound = errors.Base("value map key not found")
)

Functions

func GetDebugMode added in v1.0.6

func GetDebugMode(ctx context.Context) (bool, error)

Get the debug mode flag from the DI context.

func GetFromContext

func GetFromContext(ctx context.Context, key string) (any, error)

Get a value from a context.

Will signal `contextext.ErrInvalidContext` if the context is not valid. Will signal `contextext.ErrValueMapNotFound` if there is no value map. Will signal `ErrKeyNotFound` if the value map does not contain the key.

func PutToContext

func PutToContext(ctx context.Context, key string, value any) (context.Context, error)

Place a value in a context.

If there is no value map in the context then one will be created.

Returns a new context with the value map.

func SetDebugMode added in v1.0.6

func SetDebugMode(ctx context.Context, debugMode bool) (context.Context, error)

Set the debug mode flag in the DI context to the given value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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