eroptions

package
v0.1.0-alpha.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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.

func Exists

func Exists(o AnyOptions, key string) bool

Exists return whether the key exists in o

Types

type AnyOptions

type AnyOptions = map[string]gson.JSON // will parse on-demand

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL