Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidModifierData = errors.New("failed to apply some of the field modifiers for the provided data")
View Source
var Modifiers = map[string]ModifierFactoryFunc{}
Functions ¶
func Pick ¶
Pick converts data into a []any, map[string]any, etc. (using json marshal->unmarshal) containing only the fields from the parsed rawFields expression.
rawFields is a comma separated string of the fields to include. Nested fields should be listed with dot-notation. Fields value modifiers are also supported using the `:modifier(args)` format (see Modifiers).
In case some data fails to apply against the registered modifiers a wrapped ErrInvalidModifierData is returned that you can inspect and decide to ignore or propagate further up the execution chain.
Example:
data := map[string]any{"a": 1, "b": 2, "c": map[string]any{"c1": 11, "c2": 22}}
Pick(data, "a,c.c1") // map[string]any{"a": 1, "c": map[string]any{"c1": 11}}
Types ¶
type ModifierFactoryFunc ¶
Click to show internal directories.
Click to hide internal directories.