Documentation ¶
Index ¶
- func Copy(value interface{}) interface{}
- func CopyObject(in map[string]interface{}) map[string]interface{}
- func Equal(left interface{}, right interface{}) bool
- func Extract(src interface{}, dst interface{}) []error
- func IntersectWith(left interface{}, right interface{}, ...) interface{}
- func Merge(left interface{}, right interface{}) interface{}
- func MergeObjects(left map[string]interface{}, right map[string]interface{}) map[string]interface{}
- func MergeWith(left interface{}, right interface{}, ...) interface{}
- func TopDownWalk(w TopDownWalker, value interface{}) interface{}
- type ExtractError
- type TopDownWalker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
func Copy(value interface{}) interface{}
Create a copy of a value, so we can modify it in place.
func CopyObject ¶ added in v0.27.0
Utility so we don't need to cast.
func Equal ¶
func Equal(left interface{}, right interface{}) bool
Recursively test equality of two value trees.
func Extract ¶ added in v0.27.0
func Extract(src interface{}, dst interface{}) []error
Extract "deserializes" an interface into a target destination, using the "encoding/json" conventions.
No actual serialization happens, which means we can avoid a lot of string copies.
The extraction will try to continue even when errors are encountered and return detailed error information for each problem.
func IntersectWith ¶
func IntersectWith( left interface{}, right interface{}, resolve func(l interface{}, r interface{}) interface{}, ) interface{}
Create a new object or array containing only the parts that were in both trees. The values in the new tree are determined by the resolve argument.
func Merge ¶
func Merge(left interface{}, right interface{}) interface{}
Merges two value trees recursively. If there is a conflict, the right value is retained.
func MergeObjects ¶
Like `Merge` but has a more useful return type if you're merging objects.
func MergeWith ¶
func MergeWith( left interface{}, right interface{}, conflict func(interface{}, interface{}) interface{}, ) interface{}
MergeWith is like Merge but allows you to customize what happens on a conflict.
func TopDownWalk ¶
func TopDownWalk(w TopDownWalker, value interface{}) interface{}
Types ¶
type ExtractError ¶ added in v0.27.0
func (ExtractError) Error ¶ added in v0.27.0
func (e ExtractError) Error() string
type TopDownWalker ¶
type TopDownWalker interface { WalkArray([]interface{}) (interface{}, bool) WalkObject(map[string]interface{}) (interface{}, bool) WalkString(string) (interface{}, bool) WalkBool(bool) (interface{}, bool) }
This is a utility for recursively transforming JSON-like interface values in go.
At every step, the transformer returns the new value as well as an indication of whether or not we should continue.