/contextx

context key/value store

Primary LanguageGoMIT LicenseMIT

contextx

License Coverage GitHub Workflow Status Go Report Card Go PKG

Context value helper library.
Differences between context package this holds value in a map with mutex lock. Values readable from parent context.

go get github.com/rakunlabs/contextx

Usage

// set value first initialize context value map if not exist
ctx := contextx.WithValue(context.Background(), "secret", "xxx")

// map like access
if v, ok := contextx.Value[string](ctx, "secret"); ok {
    // v is string
}