Documentation
¶
Overview ¶
Package traverser implements traversal of unknown structures with optional callbacks
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op represents an operation to perform on a value passed to the Node callback. It is used to skip, mutate and handle error conditions.
func ErrorNoop ¶
ErrorNoop is a helper function that will return an Op that doesn't do anything but return an error
func ErrorSet ¶
ErrorSet is a helper function that will return an Op that sets the key currently being traversed to the given value and returns an error
func ErrorUnset ¶
ErrorUnset is a helper function that will return an Op that unsets the key currently being traversed and returns an error
func Set ¶
Set is a helper function that will return an Op to set the key currently being traversed to the given value
type Traverser ¶
type Traverser struct {
Map func(keys []string, key string, data reflect.Value)
Node func(keys []string, data reflect.Value) (Op, error)
Accept func(keys []string, data reflect.Value) (Op, error)
}
Traverser is the main type and contains the Map & Node callbacks to be used. Map will be called each time a Map type is encountered Node will be called for each traversable element Accept will be called each time a traversal is made