Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Separator = "."
Separator is the string to use as the delimiter between field names.
Functions ¶
func EachField ¶
EachField invokes a callback with the value, name, and kind for each field in a struct. The function returns false if the passed object cannot be resolved to a struct or non-empty slice / array (i.e. if must be a non-terminal type).
func Get ¶
func Get(obj interface{}, dotPath string) interface{}
Get the specified dot-path value by digging down and extracting from each component of the dot-path.
func ResolveUnderlying ¶
func ResolveUnderlying(obj interface{}) (resolved interface{}, ok bool)
ResolveUnderlying takes an interface{} (object) and resolves it to an instance of the underlying type through 3 varieties of resolution mutation:
1. Pointers are resolved to whatever they're referencing.
2. Slices and arrays, when not empty, are resolved to the type of the first element.
3. Test if the end result is a struct.
func TerminalFields ¶
func TerminalFields(obj interface{}) []string
TerminalFields returns a slice of strings representing the full path in dot notation for each "terminal" field, where a terminal field is defined as a primitive type (and without additional sub-fields, e.g. an int).
This implementation uses a BFS queue-based traversal to minimize stack depth.
Important note: Circular references aren't supported yet and will blow up.