Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithValueMap ¶
func WithValueMap(ctx Context, valuemap ValueMap) Context
Create a context with the value map using a default key.
func WithValueMapWithKey ¶
Create a context with the value map using the specified key.
Types ¶
type ValueMap ¶
A map-based storage structure to pass multiple values via contexts rather than many invocations of `context.WithValue` and their respective copy operations.
The main caveat with this approach is that as contexts are copied by the various `With` functions we have no means of passing changes to child contexts once the context with the value map is copied.
This is not the main aim of this type, so such functionality should not be considered. The main usage is to provide a means of passing a lot of values to some top-level context in order to avoid a lot of `WithValue` calls and a somewhat slow lookup.
func GetValueMap ¶
func GetValueMap(ctx Context) ValueMap
Get the value map (if any) from the context.
Returns nil if there is no value map.
func GetValueMapWithKey ¶
Get the value map (if any) from the context with the specified value key.