Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func WithValueMap ¶
Create a context with the value map using a default 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 ¶
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.