Documentation ¶
Overview ¶
This library provides an easy way to access nested struct visible fields relying either on the names of such fields as assigned in the json tags or by their name in the code. It relies on the well known chaining of the keys with dots so, for example, to request the value at `a.b.c` corresponds to expecting the following nested structs:
type Container struct { A TypeA `json:"a"` } type TypeA struct { B TypeB `json:"b"` } type TypeB struct { C string `json:"c"` }
The above might also have been references.
There is only one function to do so: Get. It accepts a generic type T and returns a tuple (V, error), where V is a generic type too. If, at whichever level, one of the keys in the chain is missing, the Get returns drill.ErrKeyNotFound.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrKeyNotFound = internal.ErrKeyNotFound
ErrKeyNotFound indicates that the key
Functions ¶
func Get ¶
Get is the function to use to access the fields of nested structs. It espects two inputs: the first of type T is the struct (or map) and the second is the dotted notation version of the successions of keys to access the field. The two generics are (T) the type of the input and (V) the type of the field being accessed.
Types ¶
This section is empty.