Documentation
¶
Index ¶
- func CoerceFloat64(obj interface{}) (float64, bool)
- func CoerceInt64(obj interface{}) (int64, bool)
- func CoerceString(objCursor interface{}) (string, bool)
- func Extend(to interface{}, from interface{}) error
- func Get(obj interface{}, props ...string) (interface{}, error)
- func GetFloat64(obj interface{}, props ...string) float64
- func GetInt64(obj interface{}, props ...string) int64
- func GetString(obj interface{}, props ...string) string
- func Keys(obj interface{}, parentPath ...string) []string
- func KeysRecursive(obj interface{}, parentPath ...string) []string
- func KeysRecursiveLeaves(obj interface{}, parentPath ...string) []string
- func KeysWithoutReflection(obj interface{}, parentPath ...string) []string
- func Set(obj interface{}, prop string, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CoerceFloat64 ¶
CoerceFloat64 will make a best-effort to convert the provided argument to an float64. It supports int64, int32, int, float64, float32 as acceptable inputs, but expect this list to expand further with new releases
func CoerceInt64 ¶
CoerceInt64 will make a best-effort to convert the provided argument to an int64. It supports int64, int32, int, float64, float32 as acceptable inputs, but expect this list to expand further with new releases
func CoerceString ¶
CoerceString will make a best-effort to convert the provided argument to a string. It supports string as well as anything supported by CoerceFloat64 and CoerceInt64. Expect the list of supported argument types to expand.
func Extend ¶
func Extend(to interface{}, from interface{}) error
Extend copies non-nil, non-default values from right to left
func Get ¶
Get will return the value in obj at the "location" given by dot notation property candidates. The candidates are processed in the order given, and the first non-nil result is returned. If a property
func GetFloat64 ¶
GetFloat64 does what Get does, except it continues through props until it not only gets a non-nil value, but also gets something that can be cast/coerced to a float64 value. Will return 0 if the property doesn't exist or could not be coerced. It can't be implemented by attempting to coerce Get once complete, because of the fallback logic for when more than one prop is passed.
func GetInt64 ¶
GetInt64 does what Get does, except it continues through props until it not only gets a non-nil value, but also gets something that can be cast/coerced to an int64 value. Will return 0 if the property doesn't exist or could not be coerced. It can't be implemented by attempting to coerce Get once complete, because of the fallback logic for when more than one prop is passed.
func GetString ¶
GetString does what Get does, except it continues through props until it not only gets a non-nil value, but also gets something that can be cast or coerced to a string that isn't the empty string. Will return "" if the property doesn't exist or could not be coerced. It can't be implemented by attempting to coerce Get once complete, because of the fallback logic for when more than one prop is passed.
func Keys ¶
Keys will get the list of keys for an arbitrary structure (non-recursively). In the result below, the result will be ["A", "B"], though it's best to not assume the elements are ordered.
func KeysRecursive ¶
KeysRecursive is just like Keys, only recursive. The ordering of elements in the resulting slice is not to be assumed at any time
func KeysRecursiveLeaves ¶
KeysRecursiveLeaves is like KeysRecursive, except it returns only items with no "children"
func KeysWithoutReflection ¶ added in v0.8.0
Types ¶
This section is empty.