Skip to content

worldline-go/contextx

Repository files navigation

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.

go get github.com/worldline-go/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
}