Documentation ¶
Index ¶
- func CastToError(o AnyOptions) error
- func Exists(o AnyOptions, key string) bool
- type AnyOptions
- func AsAnyOptions(s map[string]any) AnyOptions
- func AsAnyOptionsOrDollar(o any) AnyOptions
- func AsAnyOptionsOrError(o any) AnyOptions
- func Get(o AnyOptions, key string) AnyOptions
- func Merge(o AnyOptions, with AnyOptions, override bool) AnyOptions
- func RenameDollarKey(o AnyOptions, to string, force bool) AnyOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CastToError ¶
func CastToError(o AnyOptions) error
CastToError will cast the given AnyOptions to error.
Note: this function won't treat nil options as an error.
Types ¶
type AnyOptions ¶
func AsAnyOptions ¶
func AsAnyOptions(s map[string]any) AnyOptions
func AsAnyOptionsOrDollar ¶
func AsAnyOptionsOrDollar(o any) AnyOptions
AsAnyOptionsOrDollar will convert the given value to AnyOptions.
If o is map[string]any, it will return AsAnyOptions(o), or else, it will return AsAnyOptions(map[string]any{"$": o})
func AsAnyOptionsOrError ¶
func AsAnyOptionsOrError(o any) AnyOptions
AsAnyOptionsOrError will convert the given value to AnyOptions.
if o is not map[string]any, it will return AsAnyOptions(map[string]any{"error": "invalid or malformed value"})
func Get ¶
func Get(o AnyOptions, key string) AnyOptions
Get key from o
if the key is not found, return nil
func Merge ¶
func Merge(o AnyOptions, with AnyOptions, override bool) AnyOptions
Merge two AnyOptions, return a new merged object
override: if there's same key in o and with, whether to override it (make o[key] = with[key])
func RenameDollarKey ¶
func RenameDollarKey(o AnyOptions, to string, force bool) AnyOptions
RenameDollarKey rename o["$"] to o[to]
force: if true, will overwrite the existing o[to] return: same object of o