Documentation ¶
Overview ¶
Package dotnotation provides dot notation getters and setters for manipulating data structures.
Index ¶
- func DefaultGetter(target interface{}, property string) (interface{}, error)
- func DefaultParser(key string) []string
- func DefaultSetter(target interface{}, property string, value interface{}) error
- func Get(target interface{}, key string) (interface{}, error)
- func Set(target interface{}, key string, value interface{}) error
- type Accessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultGetter ¶
DefaultGetter returns the property value of a given target, or an error, supporting types like encoding/json. Supports one level of pointer indirection.
func DefaultParser ¶
DefaultParser simply converts a string key into a list of properties that must be accessed in order, to achieve the dot notation get or set.
func DefaultSetter ¶
DefaultSetter sets the property value of a given target, to a given value, or returns an error, supporting types like encoding/json. Supports one level of pointer indirection, and appending to slices if a pointer is used.
Types ¶
type Accessor ¶
type Accessor struct { // Getter returns the property value of a given target, or an error. Getter func(target interface{}, property string) (interface{}, error) // Setter sets the property value of a given target, to a given value, or returns an error. Setter func(target interface{}, property string, value interface{}) error // Parser converts a given key into a list of properties to access in order to get or set. Parser func(key string) []string }
Accessor provides two methods, Get and Set, that can be configured to handle custom data structures via the exported properties, Parser, Getter, and Setter.
var DefaultAccessor Accessor
DefaultAccessor, used for the exported Set and Get functions.