yomap

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: GPL-3.0 Imports: 1 Imported by: 0

README

yomap

import "github.com/subcon42/yotool/yomap"

Overview

YoMap is one of many simple "map management" packages in the Go world. It aims to be useful and reliable for people who use map[string]interfaces{} often.

Please understand this is a very early release; proceed with caution.

Features

* Generally eases frustration associated with the nuances of map[string]interface{} management
* Plurality support (type vs. []type distinction)
* Reduces the number of instances where switch-based type assertion, conditional if-statements, etc., are needed
* Easy-to-read code with a simple usage syntax
* At present, no explicit error handling necessary for use
* Multi-level context support (experimental, but promising!)

Planned Features

* More tests! More examples! Way, way more.
* Pointer support per type, with associated functions
* Separate "extras" branch (yotool/yomap/extras) to harbor the following for those who want them:
  * Built-in "github.com/nqd/flat" support for flattening/unflattening of logical hierarchies
  * Advanced permutations of standard (core) features, enhanced withf features from imported packages such as "reflect", "strings", etc.

Examples

The examples do not seem to render with the markup tool I am using; please see the actual Godoc version at https://godoc.org/github.com/subcon42/yotool/yomap.

Credit

Author: Jesse Coretta

Special thanks to Jason Mansfield for his awesome document (https://www.clinicallyawesome.com/2019/06/the-scenic-route-to-go-interfaces.html) that inspired this package.

Hierarchical Path Logic

Starting with version 0.2.0, yotool/yomap now supports multi-level context handling to virtually infinite proportions.

Although all relevant functions have had their string-based input signature replaced by arrays of interfaces, coordinates are provides as string slices ([]string) which are subsequently type-asserted and digested as needed.

For example, let's say you have a YoMap structure not unlike the following:

ym := YoMap{
        `firstLevel`: YoMap{
                `secondLevel`: YoMap{
                        `thirdLevel`: YoMap{
                                `coolString`: `this is pretty awesome!`,
                                `lameString`: `I don't like cats`,
                        },
                },
        },
}

And let's say you want to delete the lameString key because, come on, who doesn't like cats?! That's just crazy.

You can simply do:

path = []string{`firstLevel`,`secondLevel`,`thirdLevel`,`lameString`}
ym.Delete(path)

If you're already importing the "strings" package, you can make your life easier by writing a wrapper function around strings.Split() that converts friendly dotted-paths, such as the following string, into the []string notation YoMap expects (and perhaps vice versa via strings.Join()):

// "strings" can convert ...
`firstLevel.secondLevel.thirdLevel`

	... to  or from ...

[]string{`firstLevel`,`secondLevel`,`thirdLevel`}

As a reminder, YoMap is designed to be lightweight and, currently, imports only the "fmt" package for a very small handful of corner cases. As such, we sought not to import "strings" for such a singular and trivial task that should be easy for the user to handle.

Memory Allocation

With regards to nested YoMaps, when invoking the YoMap.Reset() function respectively, the YoMap is not simply deleted as a typical key/value "delete" built-in operation, and then replaced, nor is it overwritten out-right.

Instead, a for-loop is invoked that will traverse and delete each of its subordinate keys individually.

The reason is that memory allocation can be re-used so long as the actual "housing object" remains. In high-volume scenarios where an object may persist for extended periods of time, this may be quite an important feature.

In the case of actual DELETES of subordinate YoMap instances, the above (Reset()) is run followed by a final YoMap.Delete of the specified object key itself.

Index

Examples
Package files

bytes.go core.go doc.go floats.go ints.go nils.go util.go

Constants

const Version = `0.2.0`

We use semantic versioning (https://semver.org) for our version "number"

type YoMap

type YoMap map[string]interface{}

YoMap is merely a type alias for map[string]interface{}. It is from this alias that new methods can be extended.

func New
func New(l ...interface{}) YoMap

New() will initialize and return an instance of YoMap.

An optional integer will be accepted, representing the desired memory allocation (length).

func (YoMap) BoolInBools
func (c YoMap) BoolInBools(ss ...interface{}) bool

BoolInBools() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) BoolInInterfaces
func (c YoMap) BoolInInterfaces(ss ...interface{}) bool

BoolInInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) ByteInBytes
func (c YoMap) ByteInBytes(ss ...interface{}) bool

ByteInBytes() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) ByteInInterfaces
func (c YoMap) ByteInInterfaces(ss ...interface{}) bool

ByteInInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Complex128InComplex128s
func (c YoMap) Complex128InComplex128s(ss ...interface{}) bool

Complex128InComplex128s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Complex128InInterfaces
func (c YoMap) Complex128InInterfaces(ss ...interface{}) bool

Complex128InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Complex64InComplex64s
func (c YoMap) Complex64InComplex64s(ss ...interface{}) bool

Complex64InComplex64s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Complex64InInterfaces
func (c YoMap) Complex64InInterfaces(ss ...interface{}) bool

Complex64InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Delete
func (c YoMap) Delete(s ...interface{})

Delete() will delete the named entry (s) from an instance of YoMap.

func (YoMap) Elements
func (c YoMap) Elements(s ...interface{}) int

Elements() will return the number of non-nil array elements perceived within a YoMap key's value assignment.

If a value is not an array, but is present, 1 is returned. If nonexistent, 0 is returned.

func (YoMap) ErrorInErrors
func (c YoMap) ErrorInErrors(ss ...interface{}) bool

ErrorInErrors() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) ErrorInInterfaces
func (c YoMap) ErrorInInterfaces(ss ...interface{}) bool

ErrorInInterfaces() returns a bool indicating whether the value is present within a given array interfaces.

func (YoMap) Float32InFloat32s
func (c YoMap) Float32InFloat32s(ss ...interface{}) bool

Float32InFloat32s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Float32InInterfaces
func (c YoMap) Float32InInterfaces(ss ...interface{}) bool

Float32InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Float64InFloat64s
func (c YoMap) Float64InFloat64s(ss ...interface{}) bool

Float64InFloat64s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Float64InInterfaces
func (c YoMap) Float64InInterfaces(ss ...interface{}) bool

Float64InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Get
func (c YoMap) Get(s ...interface{}) interface{}

Get() will return the interface{} value of the named key (s), should it exists, otherwise nil will be returned. Anything returned via this function must later be type asserted properly.

func (YoMap) GetBoolEquals
func (c YoMap) GetBoolEquals(kv ...interface{}) bool

GetBoolEquals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetByteEquals
func (c YoMap) GetByteEquals(kv ...interface{}) bool

GetBytesEquals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetBytes
func (c YoMap) GetBytes(s ...interface{}) []byte

GetBytes() is a convenience method specifically tuned for byte sequences. If not a []byte, or if the search key is nonexistent, an empty byte sequence ([]byte(``)) is returned.

This method is provided due to a low degree of ambiguity with regards to the return type.

func (YoMap) GetBytesEquals
func (c YoMap) GetBytesEquals(kv ...interface{}) bool

GetBytesEquals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetComplex128Equals
func (c YoMap) GetComplex128Equals(kv ...interface{}) bool

GetComplex128Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetComplex64Equals
func (c YoMap) GetComplex64Equals(kv ...interface{}) bool

GetComplex64Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetError
func (c YoMap) GetError(s ...interface{}) error

GetError() is a convenience method specifically tuned for the error type. If not an error, or if the search key is nonexistent, nil is returned.

func (YoMap) GetErrorEquals
func (c YoMap) GetErrorEquals(kv ...interface{}) bool

GetErrorEquals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetFloat32Equals
func (c YoMap) GetFloat32Equals(kv ...interface{}) bool

GetFloat32Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetFloat64Equals
func (c YoMap) GetFloat64Equals(kv ...interface{}) bool

GetFloat64Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetInt16Equals
func (c YoMap) GetInt16Equals(kv ...interface{}) bool

GetInt16Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetInt32Equals
func (c YoMap) GetInt32Equals(kv ...interface{}) bool

GetInt32Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetInt64Equals
func (c YoMap) GetInt64Equals(kv ...interface{}) bool

GetInt64Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetInt8Equals
func (c YoMap) GetInt8Equals(kv ...interface{}) bool

GetInt8Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetIntEquals
func (c YoMap) GetIntEquals(kv ...interface{}) bool

GetIntEquals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetRuneEquals
func (c YoMap) GetRuneEquals(kv ...interface{}) bool

GetRuneEquals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetString
func (c YoMap) GetString(s ...interface{}) string

GetString() is a convenience method specifically tuned for strings. If not a string, or if the search key is nonexistent, an empty string (``) is returned.

This method is provided due to a low degree of ambiguity with regards to the return type.

func (YoMap) GetStringEquals
func (c YoMap) GetStringEquals(kv ...interface{}) bool

GetStringEquals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetUint16Equals
func (c YoMap) GetUint16Equals(kv ...interface{}) bool

GetUint16Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetUint32Equals
func (c YoMap) GetUint32Equals(kv ...interface{}) bool

GetUint32Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetUint64Equals
func (c YoMap) GetUint64Equals(kv ...interface{}) bool

GetUint64Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetUint8Equals
func (c YoMap) GetUint8Equals(kv ...interface{}) bool

GetUint8Equals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetUintEquals
func (c YoMap) GetUintEquals(kv ...interface{}) bool

GetUintEquals() will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

func (YoMap) GetYoMap
func (c YoMap) GetYoMap(s ...interface{}) YoMap

GetYoMap() is a convenience method specifically tuned for the YoMap type. If not a YoMap, or if the search key is nonexistent, nil is returned.

This method is provided due to a low degree of ambiguity with regards to the return type.

func (YoMap) Has
func (c YoMap) Has(s ...interface{}) bool

Return a bool if path exists

func (YoMap) Int16InInt16s
func (c YoMap) Int16InInt16s(ss ...interface{}) bool

Int16InInt16s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Int16InInterfaces
func (c YoMap) Int16InInterfaces(ss ...interface{}) bool

Int16InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Int32InInt32s
func (c YoMap) Int32InInt32s(ss ...interface{}) bool

Int32InInt32s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Int32InInterfaces
func (c YoMap) Int32InInterfaces(ss ...interface{}) bool

Int32InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Int64InInt64s
func (c YoMap) Int64InInt64s(ss ...interface{}) bool

Int64InInt64s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Int64InInterfaces
func (c YoMap) Int64InInterfaces(ss ...interface{}) bool

Int64InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Int8InInt8s
func (c YoMap) Int8InInt8s(ss ...interface{}) bool

Int8InInt8s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Int8InInterfaces
func (c YoMap) Int8InInterfaces(ss ...interface{}) bool

Int8InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) IntInInterfaces
func (c YoMap) IntInInterfaces(ss ...interface{}) bool

IntInInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) IntInInts
func (c YoMap) IntInInts(ss ...interface{}) bool

IntInInts() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) IsBool
func (c YoMap) IsBool(s ...interface{}) bool

IsBool() returns a bool indicating whether the value of key s within YoMap is of type bool.

func (YoMap) IsBools
func (c YoMap) IsBools(s ...interface{}) bool

IsBools() returns a bool indicating whether the value of key s within YoMap is of type []bool.

func (YoMap) IsByte
func (c YoMap) IsByte(s ...interface{}) bool

IsByte() returns a bool indicating whether the value of key s within YoMap is of type byte.

func (YoMap) IsBytes
func (c YoMap) IsBytes(s ...interface{}) bool

IsBytes() returns a bool indicating whether the value of key s within YoMap is of type []byte.

func (YoMap) IsComplex128
func (c YoMap) IsComplex128(s ...interface{}) bool

IsComplex128() returns a bool indicating whether the value of key s within YoMap is of type complex128.

func (YoMap) IsComplex128s
func (c YoMap) IsComplex128s(s ...interface{}) bool

IsComplex128s() returns a bool indicating whether the value of key s within YoMap is of type []complex128.

func (YoMap) IsComplex64
func (c YoMap) IsComplex64(s ...interface{}) bool

IsComplex64() returns a bool indicating whether the value of key s within YoMap is of type complex64.

func (YoMap) IsComplex64s
func (c YoMap) IsComplex64s(s ...interface{}) bool

IsComplex64s() returns a bool indicating whether the value of key s within YoMap is of type []complex64.

func (YoMap) IsError
func (c YoMap) IsError(s ...interface{}) bool

IsError() returns a bool indicating whether the value of key s within YoMap is of type error.

func (YoMap) IsErrors
func (c YoMap) IsErrors(s ...interface{}) bool

IsErrors() returns a bool indicating whether the value of key s within YoMap is of type []error.

func (YoMap) IsFloat32
func (c YoMap) IsFloat32(s ...interface{}) bool

IsFloat32() returns a bool indicating whether the value of key s within YoMap is of type float32.

func (YoMap) IsFloat32s
func (c YoMap) IsFloat32s(s ...interface{}) bool

IsFloat32s() returns a bool indicating whether the value of key s within YoMap is of type []float32.

func (YoMap) IsFloat64
func (c YoMap) IsFloat64(s ...interface{}) bool

IsFloat64() returns a bool indicating whether the value of key s within YoMap is of type float64.

func (YoMap) IsFloat64s
func (c YoMap) IsFloat64s(s ...interface{}) bool

IsFloat64s() returns a bool indicating whether the value of key s within YoMap is of type []float64.

func (YoMap) IsInt
func (c YoMap) IsInt(s ...interface{}) bool

IsInt() returns a bool indicating whether the value of key s within YoMap is of type int.

func (YoMap) IsInt16
func (c YoMap) IsInt16(s ...interface{}) bool

IsInt16() returns a bool indicating whether the value of key s within YoMap is of type int16.

func (YoMap) IsInt16s
func (c YoMap) IsInt16s(s ...interface{}) bool

IsInt16s() returns a bool indicating whether the value of key s within YoMap is of type []int16.

func (YoMap) IsInt32
func (c YoMap) IsInt32(s ...interface{}) bool

IsInt32() returns a bool indicating whether the value of key s within YoMap is of type int32.

func (YoMap) IsInt32s
func (c YoMap) IsInt32s(s ...interface{}) bool

IsInt32s() returns a bool indicating whether the value of key s within YoMap is of type []int32.

func (YoMap) IsInt64
func (c YoMap) IsInt64(s ...interface{}) bool

IsInt64() returns a bool indicating whether the value of key s within YoMap is of type int64.

func (YoMap) IsInt64s
func (c YoMap) IsInt64s(s ...interface{}) bool

IsInt64s() returns a bool indicating whether the value of key s within YoMap is of type []int64.

func (YoMap) IsInt8
func (c YoMap) IsInt8(s ...interface{}) bool

IsInt8() returns a bool indicating whether the value of key s within YoMap is of type int8.

func (YoMap) IsInt8s
func (c YoMap) IsInt8s(s ...interface{}) bool

IsInt8s() returns a bool indicating whether the value of key s within YoMap is of type []int8.

func (YoMap) IsInterfaces
func (c YoMap) IsInterfaces(s ...interface{}) bool

IsInterfaces() returns a bool indicating whether the value of key s within YoMap is of type []interface{}.

func (YoMap) IsInts
func (c YoMap) IsInts(s ...interface{}) bool

IsInts() returns a bool indicating whether the value of key s within YoMap is of type []int.

func (YoMap) IsNil
func (c YoMap) IsNil(s ...interface{}) bool

IsNil() returns a bool indicating whether the value of key s within YoMap is defined and its value is nil. A nonexistent key does not mean nil!

func (YoMap) IsRune
func (c YoMap) IsRune(s ...interface{}) bool

IsRune() returns a bool indicating whether the value of key s within YoMap is of type rune.

func (YoMap) IsRunes
func (c YoMap) IsRunes(s ...interface{}) bool

IsRunes() returns a bool indicating whether the value of key s within YoMap is of type []rune.

func (YoMap) IsString
func (c YoMap) IsString(s ...interface{}) bool

IsString() returns a bool indicating whether the value of key s within YoMap is of type string.

func (YoMap) IsStrings
func (c YoMap) IsStrings(s ...interface{}) bool

IsStrings() returns a bool indicating whether the value of key s within YoMap is of type []string.

func (YoMap) IsUint
func (c YoMap) IsUint(s ...interface{}) bool

IsUint() returns a bool indicating whether the value of key s within YoMap is of type uint.

func (YoMap) IsUint16
func (c YoMap) IsUint16(s ...interface{}) bool

IsUint16() returns a bool indicating whether the value of key s within YoMap is of type uint16.

func (YoMap) IsUint16s
func (c YoMap) IsUint16s(s ...interface{}) bool

IsUint16s() returns a bool indicating whether the value of key s within YoMap is of type []uint16.

func (YoMap) IsUint32
func (c YoMap) IsUint32(s ...interface{}) bool

IsUint32() returns a bool indicating whether the value of key s within YoMap is of type uint32.

func (YoMap) IsUint32s
func (c YoMap) IsUint32s(s ...interface{}) bool

IsUint32s() returns a bool indicating whether the value of key s within YoMap is of type []uint32.

func (YoMap) IsUint64
func (c YoMap) IsUint64(s ...interface{}) bool

IsUint64() returns a bool indicating whether the value of key s within YoMap is of type uint64.

func (YoMap) IsUint64s
func (c YoMap) IsUint64s(s ...interface{}) bool

IsUint64s() returns a bool indicating whether the value of key s within YoMap is of type []uint64.

func (YoMap) IsUint8
func (c YoMap) IsUint8(s ...interface{}) bool

IsUint8() returns a bool indicating whether the value of key s within YoMap is of type uint8.

func (YoMap) IsUint8s
func (c YoMap) IsUint8s(s ...interface{}) bool

IsUint8s() returns a bool indicating whether the value of key s within YoMap is of type []uint8.

func (YoMap) IsUintptr
func (c YoMap) IsUintptr(s ...interface{}) bool

IsUintptr() returns a bool indicating whether the value of key s within YoMap is of type uintptr.

func (YoMap) IsUintptrs
func (c YoMap) IsUintptrs(s ...interface{}) bool

IsUintptrs() returns a bool indicating whether the value of key s within YoMap is of type []uintptr.

func (YoMap) IsUints
func (c YoMap) IsUints(s ...interface{}) bool

IsUints() returns a bool indicating whether the value of key s within YoMap is of type []uint.

func (YoMap) IsYoMap
func (c YoMap) IsYoMap(s ...interface{}) bool

IsYoMap() returns a bool indicating whether the value of key s within YoMap is of type YoMap.

func (YoMap) IsYoMaps
func (c YoMap) IsYoMaps(s ...interface{}) bool

IsYoMaps() returns a bool indicating whether the value of key s within YoMap is of type []YoMap.

func (YoMap) Lacks
func (c YoMap) Lacks(s ...interface{}) bool

Lacks() will return a bool indicating whether or not the named key (s) does not exist.

func (YoMap) Len
func (c YoMap) Len(s ...interface{}) int

Len() will return an integer which represents the length (number of named entries) for a given instance of YoMap.

func (YoMap) NilInInterfaces
func (c YoMap) NilInInterfaces(ss ...interface{}) bool

NilInInterfaces() returns a bool indicating whether the value is present within a given array interfaces.

func (YoMap) Ready
func (c YoMap) Ready(s ...interface{}) bool

Ready() will return a bool indicating whether the instance of YoMap is initialized (non-nil).

Do not confuse "uninitialized" with "empty". A YoMap instance (and maps, for that matter) can have a length of 0 and be non-nil. Use YoMap.Len() if you're interested in the number of entries present within a YoMap instance.

func (YoMap) Reset
func (c YoMap) Reset(s ...interface{})

Reset() will traverse all keys within a given instance of YoMap; the YoMap.Delete() method is executed for each key.

No checks are done beforehand with regards to "nilness", nor are any warnings raised.

This leaves the same "space" allocated, which means that if one reuses this object instance, it is faster than running yomap.New() again.

func (YoMap) RuneInInterfaces
func (c YoMap) RuneInInterfaces(ss ...interface{}) bool

RuneInInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) RuneInRunes
func (c YoMap) RuneInRunes(ss ...interface{}) bool

RuneInRunes() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Set
func (c YoMap) Set(s ...interface{})

Set() will add the named entry (s) with the value (i) provided. Note this will overwrite anything that already exists by that name.

func (YoMap) String
func (c YoMap) String(s ...interface{})

String() will simply print out the contents in a human-readable fashion; not intended to be parsed

func (YoMap) StringInInterfaces
func (c YoMap) StringInInterfaces(ss ...interface{}) bool

StringInInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) StringInStrings
func (c YoMap) StringInStrings(ss ...interface{}) bool

StringInStrings() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) TypeOf
func (c YoMap) TypeOf(s ...interface{}) string

TypeOf() will return the string form of a key's type of value.

func (YoMap) Uint16InInterfaces
func (c YoMap) Uint16InInterfaces(ss ...interface{}) bool

Uint16InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Uint16InUint16s
func (c YoMap) Uint16InUint16s(ss ...interface{}) bool

Uint16InUint16s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Uint32InInterfaces
func (c YoMap) Uint32InInterfaces(ss ...interface{}) bool

Uint32InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Uint32InUint32s
func (c YoMap) Uint32InUint32s(ss ...interface{}) bool

Uint32InUint32s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Uint64InInterfaces
func (c YoMap) Uint64InInterfaces(ss ...interface{}) bool

Uint64InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Uint64InUint64s
func (c YoMap) Uint64InUint64s(ss ...interface{}) bool

Uint64InUint64s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) Uint8InInterfaces
func (c YoMap) Uint8InInterfaces(ss ...interface{}) bool

Uint8InInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) Uint8InUint8s
func (c YoMap) Uint8InUint8s(ss ...interface{}) bool

Uint8InUint8s() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) UintInInterfaces
func (c YoMap) UintInInterfaces(ss ...interface{}) bool

UintInInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) UintInUints
func (c YoMap) UintInUints(ss ...interface{}) bool

UintInUints() returns a bool indicating whether the value is present within a given array of same type.

func (YoMap) UintptrInInterfaces
func (c YoMap) UintptrInInterfaces(ss ...interface{}) bool

UintptrInInterfaces() returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) UintptrInUintptrs
func (c YoMap) UintptrInUintptrs(ss ...interface{}) bool

UintptrInUintptrs() returns a bool indicating whether the value is present within a given array of same type.

Documentation

Overview

Package yomap is a nifty Go-based data structure package, affording the user with extremely useful capabilities. It aims to be useful and reliable for people who use map[string]interfaces{} often.

Please understand this is a very early release; proceed with caution.

Features

  • Generally eases frustration associated with the nuances of map[string]interface{} management
  • Plurality support (type vs. []type distinction)
  • Reduces the number of instances where switch-based type assertion, conditional if-statements, etc., are needed
  • Easy-to-read code with a simple usage syntax
  • At present, no explicit error handling necessary for use
  • Multi-level context support (experimental, but promising!)

Planned Features

  • More tests! More examples! Way, way more.
  • Pointer support per type, with associated functions
  • Separate "extras" branch (yotool/yomap/extras) to harbor the following for those who want them:
  • Built-in "github.com/nqd/flat" support for flattening/unflattening of logical hierarchies
  • Advanced permutations of standard (core) features, enhanced withf features from imported packages such as "reflect", "strings", etc.

Credit

Author: Jesse Coretta

Special thanks to Jason Mansfield for his awesome document (https://www.clinicallyawesome.com/2019/06/the-scenic-route-to-go-interfaces.html) that inspired this package.

Hierarchical Path Logic

Starting with version 0.2.0, yotool/yomap now supports multi-level context handling to virtually infinite proportions.

Although all relevant functions have had their string-based input signature replaced by arrays of interfaces, coordinates are provides as string slices ([]string) which are subsequently type-asserted and digested as needed.

For example, let's say you have a YoMap structure not unlike the following:

ym := YoMap{
        `firstLevel`: YoMap{
                `secondLevel`: YoMap{
                        `thirdLevel`: YoMap{
                                `coolString`: `this is pretty awesome!`,
                                `lameString`: `I don't like cats`,
                        },
                },
        },
}

And let's say you want to delete the `lameString` key because, come on, who doesn't like cats?! That's just crazy.

You can simply do:

path = []string{`firstLevel`,`secondLevel`,`thirdLevel`,`lameString`}
ym.Delete(path)

If you're already importing the "strings" package, you can make your life easier by writing a wrapper function around strings.Split() that converts friendly dotted-paths, such as the following string, into the []string notation YoMap expects (and perhaps vice versa via strings.Join()):

// "strings" can convert ...
`firstLevel.secondLevel.thirdLevel`

	... to  or from ...

[]string{`firstLevel`,`secondLevel`,`thirdLevel`}

As a reminder, YoMap is designed to be lightweight and, currently, imports only the "fmt" package for a very small handful of corner cases. As such, we sought not to import "strings" for such a singular and trivial task that should be easy for the user to handle.

Memory Allocation

With regards to nested YoMaps, when invoking the YoMap.Reset() function respectively, the YoMap is not simply deleted as a typical key/value "delete" built-in operation, and then replaced, nor is it overwritten out-right.

Instead, a for-loop is invoked that will traverse and delete each of its subordinate keys individually.

The reason is that memory allocation can be re-used so long as the actual "housing object" remains. In high-volume scenarios where an object may persist for extended periods of time, this may be quite an important feature.

In the case of actual DELETES of subordinate YoMap instances, the above (Reset()) is run followed by a final YoMap.Delete of the specified object key itself.

Index

Examples

Constants

View Source
const Version = `0.3.8`

Version contains the string-form of the Semantic Version Number for this release. See https://semver.org for more information.

Variables

This section is empty.

Functions

This section is empty.

Types

type YoMap

type YoMap map[string]interface{}

YoMap is merely a type alias for map[string]interface{}. It is from this alias that new methods can be extended.

func New

func New(l ...interface{}) YoMap

New will initialize and return an instance of YoMap. An optional integer will be accepted, representing the desired memory allocation (length).

Example
// Uses make behind-the-scenes ...
ym := New()

// Or, allocate a specific amount of memory (make's "len" parameter) ..
// ym := New(30)

// Alternatively, you can craft your YoMap manually, though
// its not as efficient in terms of memory ...
// ym := YoMap{`myKey`:`someValue`}

ym.Set([]string{`coolString`}, `true`)
ym.Set([]string{`coolBool`}, true)

fmt.Printf("This new YoMap instance is %d entries long", ym.Len())
Output:

This new YoMap instance is 2 entries long

func (YoMap) BoolInBools

func (c YoMap) BoolInBools(ss ...interface{}) bool

BoolInBools returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolBools`: []bool{true, false, true, false},
			},
		},
	},
}

var coolBools []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolBools`}

if ym.BoolInBools(coolBools, true) {
	fmt.Println("Desired boolean found in array of bools")
}
Output:

Desired boolean found in array of bools

func (YoMap) BoolInInterfaces

func (c YoMap) BoolInInterfaces(ss ...interface{}) bool

BoolInInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see BoolInBools() example, substituting for type as appropriate ... //
Output:

func (YoMap) ByteInBytes

func (c YoMap) ByteInBytes(ss ...interface{}) bool

ByteInBytes returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolBytes`: []byte{byte(0x2)},
			},
		},
	},
}

var coolBytes []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolBytes`}

if ym.ByteInBytes(coolBytes, byte(0x2)) {
	fmt.Println("Desired byte sequence found in array of bytes")
}
Output:

Desired byte sequence found in array of bytes

func (YoMap) ByteInInterfaces

func (c YoMap) ByteInInterfaces(ss ...interface{}) bool

ByteInInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see ByteInBytes() example, substituting for type as appropriate ... //
Output:

func (YoMap) Complex128InComplex128s

func (c YoMap) Complex128InComplex128s(ss ...interface{}) bool

Complex128InComplex128s returns a bool indicating whether the value is present within a given array of same type.

Example
// Some complex numbers
c128 := 0.17 + 0.4i
c128a := 0.61 + 0.4i
c128b := 0.34 + 0.1i
c128c := 0.59 + 0.5i

ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolNumbers`: []complex128{complex128(c128), complex128(c128a), complex128(c128b), complex128(c128c)},
			},
		},
	},
}

var coolNumbers []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolNumbers`}

if ym.Complex128InComplex128s(coolNumbers, complex128(c128a)) {
	fmt.Println("Desired complex128 found in array of complex128s")
}
Output:

Desired complex128 found in array of complex128s

func (YoMap) Complex128InInterfaces

func (c YoMap) Complex128InInterfaces(ss ...interface{}) bool

Complex128InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see the Complex128inComplex128s() example, substituting for type as appropriate ...//
Output:

func (YoMap) Complex64InComplex64s

func (c YoMap) Complex64InComplex64s(ss ...interface{}) bool

Complex64InComplex64s returns a bool indicating whether the value is present within a given array of same type.

Example
// Some complex numbers
c64 := 0.17 + 0.4i
c64a := 0.61 + 0.4i
c64b := 0.34 + 0.1i
c64c := 0.59 + 0.5i

ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolNumbers`: []complex64{complex64(c64), complex64(c64a), complex64(c64b), complex64(c64c)},
			},
		},
	},
}

var coolNumbers []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolNumbers`}

if ym.Complex64InComplex64s(coolNumbers, complex64(c64a)) {
	fmt.Println("Desired complex64 found in array of complex64s")
}
Output:

Desired complex64 found in array of complex64s

func (YoMap) Complex64InInterfaces

func (c YoMap) Complex64InInterfaces(ss ...interface{}) bool

Complex64InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see the Complex64inComplex64s() example, substituting for type as appropriate ...//
Output:

func (YoMap) Delete

func (c YoMap) Delete(s ...interface{})

Delete will delete the named entry (s) from an instance of YoMap.

Example
ym := YoMap{
	`coolString`: `true`,
	`coolBytes`:  []byte(`...someBytes...`),
	`coolBool`:   true,
}
ym.Delete([]string{`coolString`})
fmt.Printf("YoMap should be %d entries long now", ym.Len())
Output:

YoMap should be 2 entries long now

func (YoMap) Elements

func (c YoMap) Elements(s ...interface{}) int

Elements will return the number of non-nil array elements perceived within a YoMap key's value assignment. If a value is not an array, but is present, 1 is returned. If nonexistent, 0 is returned.

Example
// Some weird array of mixed-types
ifs := make([]interface{}, 5)
ifs[0] = float32(3.14)
ifs[1] = float64(3.14159)
ifs[2] = []byte(`{"jsonKey": "someValue"}`)
ifs[3] = string("Testing 1 2 3")
//ifs[4] = bool(true)	// leave one unpopulated

ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`mixed`: ifs,
			`thirdLevel`: YoMap{
				`coolFloats`: []float64{3.14, 3.1415, 3.14159},
			},
		},
	},
	`coolString`:  `very cool`,
	`coolStrings`: []string{`string1`, `string2`, `string3`, `string4`, `string5`, `string6`},
	`coolInts`:    []int{1, 2, 3, 4},
	`coolBools`:   []bool{true, false, true, false, true},
}

els := ym.Elements([]string{`coolStrings`})
eli := ym.Elements([]string{`coolInts`})
elb := ym.Elements([]string{`coolBools`})
elf := ym.Elements([]string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolFloats`})
elm := ym.Elements([]string{`firstLevel`, `secondLevel`, `mixed`})
lie := ym.Elements([]string{`coolString`})
empty := ym.Elements()
fmt.Printf("Strings: %d, Ints: %d, Bools: %d, Floats: %d, Mixed: %d, Single String: %d, Empty: %d", els, eli, elb, elf, elm, lie, empty)
Output:

Strings: 6, Ints: 4, Bools: 5, Floats: 3, Mixed: 4, Single String: 1, Empty: 0

func (YoMap) ErrorInErrors

func (c YoMap) ErrorInErrors(ss ...interface{}) bool

ErrorInErrors returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []error{fmt.Errorf("Error1"), fmt.Errorf("Error2"), fmt.Errorf("Error3")},
			},
		},
	},
}

var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.ErrorInErrors(coolMulti, fmt.Errorf("Error1")) {
	fmt.Println("Desired error found in array of errors")
}
Output:

Desired error found in array of errors

func (YoMap) ErrorInInterfaces

func (c YoMap) ErrorInInterfaces(ss ...interface{}) bool

ErrorInInterfaces returns a bool indicating whether the value is present within a given array interfaces.

Example
// ... see the ErrorInErrors() example, substituting for type as appropriate ...//
Output:

func (YoMap) Float32InFloat32s

func (c YoMap) Float32InFloat32s(ss ...interface{}) bool

Float32InFloat32s returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolNumbers`: []float32{3.14, 3.141, 3.1415, 3.14159},
			},
		},
	},
}

var coolNumbers []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolNumbers`}

if ym.Float32InFloat32s(coolNumbers, float32(3.14159)) {
	fmt.Println("Desired float32 found in array of float32s")
}
Output:

Desired float32 found in array of float32s

func (YoMap) Float32InInterfaces

func (c YoMap) Float32InInterfaces(ss ...interface{}) bool

Float32InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see Float32InFloat32s() example, substituting for type as appropriate ... //
Output:

func (YoMap) Float64InFloat64s

func (c YoMap) Float64InFloat64s(ss ...interface{}) bool

Float64InFloat64s returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolNumbers`: []float64{3.14, 3.141, 3.1415, 3.14159},
			},
		},
	},
}

var coolNumbers []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolNumbers`}

if ym.Float64InFloat64s(coolNumbers, float64(3.14159)) {
	fmt.Println("Desired float64 found in array of float64s")
}
Output:

Desired float64 found in array of float64s

func (YoMap) Float64InInterfaces

func (c YoMap) Float64InInterfaces(ss ...interface{}) bool

Float64InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see Float64InFloat64s() example, substituting for type as appropriate ... //
Output:

func (YoMap) Get

func (c YoMap) Get(s ...interface{}) interface{}

Get will return the interface{} value of the named key (s), should it exists, otherwise nil will be returned. Anything returned via this function must later be type asserted properly.

Example
ym := YoMap{
	`coolString`: true,
	`coolBytes`:  []byte(`bytes`),
	`coolBool`:   true,
}
cool := ym.Get([]string{`coolBool`}) // will be an interface{} unless type-asserted!
if _, isBool := cool.(bool); isBool {
	fmt.Printf("It's a bool? %v", isBool)
}
Output:

It's a bool? true

func (YoMap) GetBoolEquals

func (c YoMap) GetBoolEquals(kv ...interface{}) bool

GetBoolEquals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolBool`: true,
			},
		},
	},
}

var (
	coolBool []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolBool`}
)

if ym.GetBoolEquals(coolBool, true) {
	fmt.Println("coolBool matched!")
}
Output:

coolBool matched!

func (YoMap) GetByteEquals

func (c YoMap) GetByteEquals(kv ...interface{}) bool

GetByteEquals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolByte`: byte(0x1),
			},
		},
	},
}

var (
	coolByte []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolByte`}
)

if ym.GetByteEquals(coolByte, byte(0x1)) {
	fmt.Println("coolByte matched!")
}
Output:

coolByte matched!

func (YoMap) GetBytes

func (c YoMap) GetBytes(s ...interface{}) []byte

GetBytes is a convenience method specifically tuned for byte sequences. If not a []byte, or if the search key is nonexistent, an empty byte sequence ([]byte(“)) is returned. This method is provided due to a low degree of ambiguity with regards to the return type.

Example
ym := YoMap{
	`coolString`: true,
	`coolBytes`:  []byte(`false`),
	`coolBool`:   true,
}
ym.Set([]string{`coolBytes`}, []byte(`true`))
coolBytes := ym.GetBytes([]string{`coolBytes`}) // will be []byte, no type assertion needed
fmt.Printf("%s: %v", string(coolBytes), coolBytes)
Output:

true: [116 114 117 101]

func (YoMap) GetBytesEquals

func (c YoMap) GetBytesEquals(kv ...interface{}) bool

GetBytesEquals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolBytes`: []byte(`{"someKey":"someValue"}`),
			},
		},
	},
}

var (
	coolBytes []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolBytes`}
)

if ym.GetBytesEquals(coolBytes, []byte(`{"someKey":"someValue"}`)) {
	fmt.Println("coolBytes matched!")
}
Output:

coolBytes matched!

func (YoMap) GetComplex128Equals

func (c YoMap) GetComplex128Equals(kv ...interface{}) bool

GetComplex128Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolComplex128`: 0.61 + 0.4i,
			},
		},
	},
}

var (
	coolComplex128 []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolComplex128`}
)

if ym.GetComplex128Equals(coolComplex128, 0.61+0.4i) {
	fmt.Println("coolComplex128 matched!")
}
Output:

coolComplex128 matched!

func (YoMap) GetComplex64Equals

func (c YoMap) GetComplex64Equals(kv ...interface{}) bool

GetComplex64Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolComplex64`: complex64(0.61 + 0.4i),
			},
		},
	},
}

var (
	coolComplex64 []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolComplex64`}
)

if ym.GetComplex64Equals(coolComplex64, complex64(0.61+0.4i)) {
	fmt.Println("coolComplex64 matched!")
}
Output:

coolComplex64 matched!

func (YoMap) GetError

func (c YoMap) GetError(s ...interface{}) error

GetError is a convenience method specifically tuned for the error type. If not an error, or if the search key is nonexistent, nil is returned.

Example
ym := YoMap{
	`coolError`: fmt.Errorf("This is a pretty rad error"),
	`coolBool`:  true,
}
coolError := ym.GetError([]string{`coolError`}) // will be error, no type assertion needed
fmt.Printf("%s", coolError.Error())
Output:

This is a pretty rad error

func (YoMap) GetErrorEquals

func (c YoMap) GetErrorEquals(kv ...interface{}) bool

GetErrorEquals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolError`: fmt.Errorf("This is a pretty rad error"),
			},
		},
	},
}

var (
	coolError []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolError`}
)

if ym.GetErrorEquals(coolError, fmt.Errorf("This is a pretty rad error")) {
	fmt.Println("coolError matched!")
}
Output:

coolError matched!

func (YoMap) GetFloat32Equals

func (c YoMap) GetFloat32Equals(kv ...interface{}) bool

GetFloat32Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolFloat32`: float32(3.14),
			},
		},
	},
}

var (
	coolFloat32 []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolFloat32`}
)

if ym.GetFloat32Equals(coolFloat32, float32(3.14)) {
	fmt.Println("coolFloat32 matched!")
}
Output:

coolFloat32 matched!

func (YoMap) GetFloat64Equals

func (c YoMap) GetFloat64Equals(kv ...interface{}) bool

GetFloat64Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolFloat64`: 3.14,
			},
		},
	},
}

var (
	coolFloat64 []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolFloat64`}
)

if ym.GetFloat64Equals(coolFloat64, 3.14) {
	fmt.Println("coolFloat64 matched!")
}
Output:

coolFloat64 matched!

func (YoMap) GetInt16Equals

func (c YoMap) GetInt16Equals(kv ...interface{}) bool

GetInt16Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
// See GetIntEquals() example, substituting for desired int type
Output:

func (YoMap) GetInt32Equals

func (c YoMap) GetInt32Equals(kv ...interface{}) bool

GetInt32Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
// See GetIntEquals() example, substituting for desired int type
Output:

func (YoMap) GetInt64Equals

func (c YoMap) GetInt64Equals(kv ...interface{}) bool

GetInt64Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
// See GetIntEquals() example, substituting for desired int type
Output:

func (YoMap) GetInt8Equals

func (c YoMap) GetInt8Equals(kv ...interface{}) bool

GetInt8Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
// See GetIntEquals() example, substituting for desired int type
Output:

func (YoMap) GetIntEquals

func (c YoMap) GetIntEquals(kv ...interface{}) bool

GetIntEquals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolInt`: 42,
			},
		},
	},
}

var (
	coolInt []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolInt`}
)

if ym.GetIntEquals(coolInt, 42) {
	fmt.Println("coolInt matched!")
}
Output:

coolInt matched!

func (YoMap) GetRuneEquals

func (c YoMap) GetRuneEquals(kv ...interface{}) bool

GetRuneEquals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolRune`: 'c',
			},
		},
	},
}

var (
	coolRune []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolRune`}
)

if ym.GetRuneEquals(coolRune, 'c') {
	fmt.Println("coolRune matched!")
}
Output:

coolRune matched!

func (YoMap) GetString

func (c YoMap) GetString(s ...interface{}) string

GetString is a convenience method specifically tuned for strings. If not a string, or if the search key is nonexistent, an empty string (“) is returned. This method is provided due to a low degree of ambiguity with regards to the return type.

Example
ym := YoMap{
	`coolString`: `false`,
	`coolBytes`:  []byte(`false`),
	`coolBool`:   true,
}
ym.Set([]string{`coolString`}, `true`)
coolString := ym.GetString([]string{`coolString`}) // will be string, no type assertion needed
fmt.Printf("%s", coolString)
Output:

true

func (YoMap) GetStringEquals

func (c YoMap) GetStringEquals(kv ...interface{}) bool

GetStringEquals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolString`: `cats rule!`,
			},
		},
	},
	`coolKey`: `importantV@lu3`,
}

var (
	coolString []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolString`}
	coolKey    []string = []string{`coolKey`}
)

if ym.GetStringEquals(coolKey, `importantV@lu3`) && ym.GetStringEquals(coolString, `cats rule!`) {
	fmt.Println("coolString and coolKey both matched!")
}
Output:

coolString and coolKey both matched!

func (YoMap) GetUint16Equals

func (c YoMap) GetUint16Equals(kv ...interface{}) bool

GetUint16Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
// See GetUintEquals() example, substituting for desired int type
Output:

func (YoMap) GetUint32Equals

func (c YoMap) GetUint32Equals(kv ...interface{}) bool

GetUint32Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
// See GetUintEquals() example, substituting for desired int type
Output:

func (YoMap) GetUint64Equals

func (c YoMap) GetUint64Equals(kv ...interface{}) bool

GetUint64Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
// See GetUintEquals() example, substituting for desired int type
Output:

func (YoMap) GetUint8Equals

func (c YoMap) GetUint8Equals(kv ...interface{}) bool

GetUint8Equals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
// See GetUintEquals() example, substituting for desired int type
Output:

func (YoMap) GetUintEquals

func (c YoMap) GetUintEquals(kv ...interface{}) bool

GetUintEquals will return a bool indicating whether the provided key (k) exists and is assigned a value equal to the provided value (v).

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolUint`: uint(42),
			},
		},
	},
}

var (
	coolUint []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolUint`}
)

if ym.GetUintEquals(coolUint, uint(42)) {
	fmt.Println("coolUint matched!")
}
Output:

coolUint matched!

func (YoMap) GetYoMap

func (c YoMap) GetYoMap(s ...interface{}) YoMap

GetYoMap is a convenience method specifically tuned for the YoMap type. If not a YoMap, or if the search key is nonexistent, nil is returned. This method is provided due to a low degree of ambiguity with regards to the return type.

Example
ym := YoMap{
	`coolYoMap`: YoMap{
		`otherCoolString`: false,
		`otherCoolBytes`:  []byte(`false`),
		`coolBool`:        true,
	},
	`coolString`: `false`,
	`coolBytes`:  []byte(`false`),
	`coolBool`:   true,
}
cym := ym.GetYoMap([]string{`coolYoMap`}) // will be YoMap, no type assertion needed
fmt.Printf("YoMap.CoolYoMap is %d entries long", cym.Len())
Output:

YoMap.CoolYoMap is 3 entries long

func (YoMap) Has

func (c YoMap) Has(s ...interface{}) bool

Has will return a bool if path exists

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolString`: `this is pretty awesome!`,
				`lameString`: `I don't like cats`,
			},
		},
	},
}
var path []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolString`}
if ym.Has(path) && ym.IsString(path) {
	g := ym.Get(path).(string)
	fmt.Printf("Found: %s", g)
}
Output:

Found: this is pretty awesome!

func (YoMap) Int16InInt16s

func (c YoMap) Int16InInt16s(ss ...interface{}) bool

Int16InInt16s returns a bool indicating whether the value is present within a given array of same type.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) Int16InInterfaces

func (c YoMap) Int16InInterfaces(ss ...interface{}) bool

Int16InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) Int32InInt32s

func (c YoMap) Int32InInt32s(ss ...interface{}) bool

Int32InInt32s returns a bool indicating whether the value is present within a given array of same type.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) Int32InInterfaces

func (c YoMap) Int32InInterfaces(ss ...interface{}) bool

Int32InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) Int64InInt64s

func (c YoMap) Int64InInt64s(ss ...interface{}) bool

Int64InInt64s returns a bool indicating whether the value is present within a given array of same type.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) Int64InInterfaces

func (c YoMap) Int64InInterfaces(ss ...interface{}) bool

Int64InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) Int8InInt8s

func (c YoMap) Int8InInt8s(ss ...interface{}) bool

Int8InInt8s returns a bool indicating whether the value is present within a given array of same type.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) Int8InInterfaces

func (c YoMap) Int8InInterfaces(ss ...interface{}) bool

Int8InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) IntInInterfaces

func (c YoMap) IntInInterfaces(ss ...interface{}) bool

IntInInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) IntInInts

func (c YoMap) IntInInts(ss ...interface{}) bool

IntInInts returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolNumbers`: []int{1, 2, 3, 4},
			},
		},
	},
}

var coolNumbers []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolNumbers`}

if ym.IntInInts(coolNumbers, 4) {
	fmt.Println("Desired int found in array of ints")
}
Output:

Desired int found in array of ints

func (YoMap) IsBool

func (c YoMap) IsBool(s ...interface{}) bool

IsBool returns a bool indicating whether the value of key s within YoMap is of type bool.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: true,
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []bool{false, false, false, false, true},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsBool(coolSingle) && ym.IsBools(coolMulti) {
	fmt.Println("coolSingle is a bool, and coolMulti is an array of bools")
}
Output:

coolSingle is a bool, and coolMulti is an array of bools

func (YoMap) IsBools

func (c YoMap) IsBools(s ...interface{}) bool

IsBools returns a bool indicating whether the value of key s within YoMap is of type []bool.

Example
// ... see the IsBool() example ...//
Output:

func (YoMap) IsByte

func (c YoMap) IsByte(s ...interface{}) bool

IsByte returns a bool indicating whether the value of key s within YoMap is of type byte.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: byte(0x1),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []byte(`{"jsonKey": "jsonValue"}`),
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsByte(coolSingle) && ym.IsBytes(coolMulti) {
	fmt.Println("coolSingle is a byte, and coolMulti is an array of bytes")
}
Output:

coolSingle is a byte, and coolMulti is an array of bytes

func (YoMap) IsBytes

func (c YoMap) IsBytes(s ...interface{}) bool

IsBytes returns a bool indicating whether the value of key s within YoMap is of type []byte.

Example
// ... see the IsByte() example ...//
Output:

func (YoMap) IsComplex128

func (c YoMap) IsComplex128(s ...interface{}) bool

IsComplex128 returns a bool indicating whether the value of key s within YoMap is of type complex128.

Example
// Some complex numbers
c128 := 0.17 + 0.4i
c128a := 0.61 + 0.4i
c128b := 0.34 + 0.1i
c128c := 0.59 + 0.5i

ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: c128,
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []complex128{c128a, c128b, c128c},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsComplex128(coolSingle) && ym.IsComplex128s(coolMulti) {
	fmt.Println("coolSingle is a complex128, and coolMulti is an array of complex128s")
}
Output:

coolSingle is a complex128, and coolMulti is an array of complex128s

func (YoMap) IsComplex128s

func (c YoMap) IsComplex128s(s ...interface{}) bool

IsComplex128s returns a bool indicating whether the value of key s within YoMap is of type []complex128.

Example
// ... see the IsComplex128() example ...//
Output:

func (YoMap) IsComplex64

func (c YoMap) IsComplex64(s ...interface{}) bool

IsComplex64 returns a bool indicating whether the value of key s within YoMap is of type complex64.

Example
// Some complex numbers
c64 := 0.17 + 0.4i
c64a := 0.61 + 0.4i
c64b := 0.34 + 0.1i
c64c := 0.59 + 0.5i

ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: complex64(c64),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []complex64{complex64(c64a), complex64(c64b), complex64(c64c)},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsComplex64(coolSingle) && ym.IsComplex64s(coolMulti) {
	fmt.Println("coolSingle is a complex64, and coolMulti is an array of complex64s")
}
Output:

coolSingle is a complex64, and coolMulti is an array of complex64s

func (YoMap) IsComplex64s

func (c YoMap) IsComplex64s(s ...interface{}) bool

IsComplex64s returns a bool indicating whether the value of key s within YoMap is of type []complex64.

Example
// ... see the IsComplex64() example ...//
Output:

func (YoMap) IsError

func (c YoMap) IsError(s ...interface{}) bool

IsError returns a bool indicating whether the value of key s within YoMap is of type error.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: fmt.Errorf("Error 501: User dislikes cats"),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []error{fmt.Errorf("Error1"), fmt.Errorf("Error2"), fmt.Errorf("Error3")},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsError(coolSingle) && ym.IsErrors(coolMulti) {
	fmt.Println("coolSingle is an error, and coolMulti is an array of errors")
}
Output:

coolSingle is an error, and coolMulti is an array of errors

func (YoMap) IsErrors

func (c YoMap) IsErrors(s ...interface{}) bool

IsErrors returns a bool indicating whether the value of key s within YoMap is of type []error.

Example
// ... see the IsError() example ...//
Output:

func (YoMap) IsFloat32

func (c YoMap) IsFloat32(s ...interface{}) bool

IsFloat32 returns a bool indicating whether the value of key s within YoMap is of type float32.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: float32(3.14),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []float32{3.14, 3.141, 3.1415},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsFloat32(coolSingle) && ym.IsFloat32s(coolMulti) {
	fmt.Println("coolSingle is a float32, and coolMulti is an array of float32s")
}
Output:

coolSingle is a float32, and coolMulti is an array of float32s

func (YoMap) IsFloat32s

func (c YoMap) IsFloat32s(s ...interface{}) bool

IsFloat32s returns a bool indicating whether the value of key s within YoMap is of type []float32.

Example
// ... see the IsFloat32() example ...//
Output:

func (YoMap) IsFloat64

func (c YoMap) IsFloat64(s ...interface{}) bool

IsFloat64 returns a bool indicating whether the value of key s within YoMap is of type float64.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: float64(3.14),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []float64{3.14, 3.141, 3.1415},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsFloat64(coolSingle) && ym.IsFloat64s(coolMulti) {
	fmt.Println("coolSingle is a float64, and coolMulti is an array of float64s")
}
Output:

coolSingle is a float64, and coolMulti is an array of float64s

func (YoMap) IsFloat64s

func (c YoMap) IsFloat64s(s ...interface{}) bool

IsFloat64s returns a bool indicating whether the value of key s within YoMap is of type []float64.

Example
// ... see the IsFloat64() example ...//
Output:

func (YoMap) IsInt

func (c YoMap) IsInt(s ...interface{}) bool

IsInt returns a bool indicating whether the value of key s within YoMap is of type int.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: int(3054957437),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []int{0, -1, 78243, 342},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsInt(coolSingle) && ym.IsInts(coolMulti) {
	fmt.Println("coolSingle is a int, and coolMulti is an array of ints")
}
Output:

coolSingle is a int, and coolMulti is an array of ints

func (YoMap) IsInt16

func (c YoMap) IsInt16(s ...interface{}) bool

IsInt16 returns a bool indicating whether the value of key s within YoMap is of type int16.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: int16(3054),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []int16{0, -1, 782, 342},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsInt16(coolSingle) && ym.IsInt16s(coolMulti) {
	fmt.Println("coolSingle is a int, and coolMulti is an array of ints")
}
Output:

coolSingle is a int, and coolMulti is an array of ints

func (YoMap) IsInt16s

func (c YoMap) IsInt16s(s ...interface{}) bool

IsInt16s returns a bool indicating whether the value of key s within YoMap is of type []int16.

Example
// ... see the IsInt16() example ...//
Output:

func (YoMap) IsInt32

func (c YoMap) IsInt32(s ...interface{}) bool

IsInt32 returns a bool indicating whether the value of key s within YoMap is of type int32.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: int32(3054957),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []int32{0, -1, 78243, 342},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsInt32(coolSingle) && ym.IsInt32s(coolMulti) {
	fmt.Println("coolSingle is a int, and coolMulti is an array of ints")
}
Output:

coolSingle is a int, and coolMulti is an array of ints

func (YoMap) IsInt32s

func (c YoMap) IsInt32s(s ...interface{}) bool

IsInt32s returns a bool indicating whether the value of key s within YoMap is of type []int32.

Example
// ... see the IsInt32() example ...//
Output:

func (YoMap) IsInt64

func (c YoMap) IsInt64(s ...interface{}) bool

IsInt64 returns a bool indicating whether the value of key s within YoMap is of type int64.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: int64(3054957437),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []int64{0, -1, 78243, 342},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsInt64(coolSingle) && ym.IsInt64s(coolMulti) {
	fmt.Println("coolSingle is a int, and coolMulti is an array of ints")
}
Output:

coolSingle is a int, and coolMulti is an array of ints

func (YoMap) IsInt64s

func (c YoMap) IsInt64s(s ...interface{}) bool

IsInt64s returns a bool indicating whether the value of key s within YoMap is of type []int64.

Example
// ... see the IsInt64() example ...//
Output:

func (YoMap) IsInt8

func (c YoMap) IsInt8(s ...interface{}) bool

IsInt8 returns a bool indicating whether the value of key s within YoMap is of type int8.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: int8(30),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []int8{0, -1, 78, 42},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsInt8(coolSingle) && ym.IsInt8s(coolMulti) {
	fmt.Println("coolSingle is a int, and coolMulti is an array of ints")
}
Output:

coolSingle is a int, and coolMulti is an array of ints

func (YoMap) IsInt8s

func (c YoMap) IsInt8s(s ...interface{}) bool

IsInt8s returns a bool indicating whether the value of key s within YoMap is of type []int8.

Example
// ... see the IsInt8() example ...//
Output:

func (YoMap) IsInterfaces

func (c YoMap) IsInterfaces(s ...interface{}) bool

IsInterfaces returns a bool indicating whether the value of key s within YoMap is of type []interface{}.

Example
// Some weird array of mixed-types
ifs := make([]interface{}, 4)
ifs[0] = float32(3.14)
ifs[1] = float64(3.14159)
ifs[2] = []byte(`{"jsonKey": "someValue"}`)
ifs[3] = string("Testing 1 2 3")

ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: ifs,
			},
		},
	},
}

var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsInterfaces(coolMulti) {
	fmt.Println("coolMulti is an array of interfaces")
}
Output:

coolMulti is an array of interfaces

func (YoMap) IsInts

func (c YoMap) IsInts(s ...interface{}) bool

IsInts returns a bool indicating whether the value of key s within YoMap is of type []int.

Example
// ... see the IsInt() example ...//
Output:

func (YoMap) IsNil

func (c YoMap) IsNil(s ...interface{}) bool

IsNil returns a bool indicating whether the value of key s within YoMap is defined **and** its value is nil. A nonexistent key does not mean nil!

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: nil,
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []error{nil, nil, nil},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}

if ym.IsNil(coolSingle) {
	fmt.Println("coolSingle is a nil")
}
Output:

coolSingle is a nil

func (YoMap) IsRune

func (c YoMap) IsRune(s ...interface{}) bool

IsRune returns a bool indicating whether the value of key s within YoMap is of type rune.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: 'c',
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []rune{'a', 'b', 'c'},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsRune(coolSingle) && ym.IsRunes(coolMulti) {
	fmt.Println("coolSingle is a rune, and coolMulti is an array of runes")
}
Output:

coolSingle is a rune, and coolMulti is an array of runes

func (YoMap) IsRunes

func (c YoMap) IsRunes(s ...interface{}) bool

IsRunes returns a bool indicating whether the value of key s within YoMap is of type []rune.

Example
// ... see the IsRune() example ...//
Output:

func (YoMap) IsString

func (c YoMap) IsString(s ...interface{}) bool

IsString returns a bool indicating whether the value of key s within YoMap is of type string.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: `quite cool`,
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []string{`false`, `blarg`, `_____`, `Hello.`},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsString(coolSingle) && ym.IsStrings(coolMulti) {
	fmt.Println("coolSingle is a string, and coolMulti is an array of strings")
}
Output:

coolSingle is a string, and coolMulti is an array of strings

func (YoMap) IsStrings

func (c YoMap) IsStrings(s ...interface{}) bool

IsStrings returns a bool indicating whether the value of key s within YoMap is of type []string.

Example
// ... see the IsString() example ...//
Output:

func (YoMap) IsUint

func (c YoMap) IsUint(s ...interface{}) bool

IsUint returns a bool indicating whether the value of key s within YoMap is of type uint.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: uint(3054957437),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []uint{0, 53, 78243, 342},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsUint(coolSingle) && ym.IsUints(coolMulti) {
	fmt.Println("coolSingle is a uint, and coolMulti is an array of uints")
}
Output:

coolSingle is a uint, and coolMulti is an array of uints

func (YoMap) IsUint16

func (c YoMap) IsUint16(s ...interface{}) bool

IsUint16 returns a bool indicating whether the value of key s within YoMap is of type uint16.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: uint16(30545),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []uint16{0, 53, 7243, 342},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsUint16(coolSingle) && ym.IsUint16s(coolMulti) {
	fmt.Println("coolSingle is a uint, and coolMulti is an array of uints")
}
Output:

coolSingle is a uint, and coolMulti is an array of uints

func (YoMap) IsUint16s

func (c YoMap) IsUint16s(s ...interface{}) bool

IsUint16s returns a bool indicating whether the value of key s within YoMap is of type []uint16.

Example
// ... see the IsUint16() example ...//
Output:

func (YoMap) IsUint32

func (c YoMap) IsUint32(s ...interface{}) bool

IsUint32 returns a bool indicating whether the value of key s within YoMap is of type uint32.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: uint32(30549577),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []uint32{0, 53, 78243, 342},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsUint32(coolSingle) && ym.IsUint32s(coolMulti) {
	fmt.Println("coolSingle is a uint, and coolMulti is an array of uints")
}
Output:

coolSingle is a uint, and coolMulti is an array of uints

func (YoMap) IsUint32s

func (c YoMap) IsUint32s(s ...interface{}) bool

IsUint32s returns a bool indicating whether the value of key s within YoMap is of type []uint32.

Example
// ... see the IsUint32() example ...//
Output:

func (YoMap) IsUint64

func (c YoMap) IsUint64(s ...interface{}) bool

IsUint64 returns a bool indicating whether the value of key s within YoMap is of type uint64.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: uint64(3054957437),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []uint64{0, 53, 78243, 342},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsUint64(coolSingle) && ym.IsUint64s(coolMulti) {
	fmt.Println("coolSingle is a uint, and coolMulti is an array of uints")
}
Output:

coolSingle is a uint, and coolMulti is an array of uints

func (YoMap) IsUint64s

func (c YoMap) IsUint64s(s ...interface{}) bool

IsUint64s returns a bool indicating whether the value of key s within YoMap is of type []uint64.

Example
// ... see the IsUint64() example ...//
Output:

func (YoMap) IsUint8

func (c YoMap) IsUint8(s ...interface{}) bool

IsUint8 returns a bool indicating whether the value of key s within YoMap is of type uint8.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: uint8(30),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []uint8{0, 53, 254, 142},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsUint8(coolSingle) && ym.IsUint8s(coolMulti) {
	fmt.Println("coolSingle is a uint, and coolMulti is an array of uints")
}
Output:

coolSingle is a uint, and coolMulti is an array of uints

func (YoMap) IsUint8s

func (c YoMap) IsUint8s(s ...interface{}) bool

IsUint8s returns a bool indicating whether the value of key s within YoMap is of type []uint8.

Example
// ... see the IsUint8() example ...//
Output:

func (YoMap) IsUintptr

func (c YoMap) IsUintptr(s ...interface{}) bool

IsUintptr returns a bool indicating whether the value of key s within YoMap is of type uintptr.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`coolSingle`: uintptr(437853),
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []uintptr{432875, 53234, 18845, 24536},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `coolSingle`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.IsUintptr(coolSingle) && ym.IsUintptrs(coolMulti) {
	fmt.Println("coolSingle is a uintptr, and coolMulti is an array of uintptrs")
}
Output:

coolSingle is a uintptr, and coolMulti is an array of uintptrs

func (YoMap) IsUintptrs

func (c YoMap) IsUintptrs(s ...interface{}) bool

IsUintptrs returns a bool indicating whether the value of key s within YoMap is of type []uintptr.

Example
// ... see the IsUintptr() example ...//
Output:

func (YoMap) IsUints

func (c YoMap) IsUints(s ...interface{}) bool

IsUints returns a bool indicating whether the value of key s within YoMap is of type []uint.

Example
// ... see the IsUint() example ...//
Output:

func (YoMap) IsYoMap

func (c YoMap) IsYoMap(s ...interface{}) bool

IsYoMap returns a bool indicating whether the value of key s within YoMap is of type YoMap.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: []YoMap{
				{`test`: `haha`},
				{`notfunny`: `true`},
			},
		},
	},
}

var coolSingle []string = []string{`firstLevel`, `secondLevel`}
var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`}

if ym.IsYoMap(coolSingle) && ym.IsYoMaps(coolMulti) {
	fmt.Println("coolSingle is a yomap, and coolMulti is an array of yomaps")
}
Output:

coolSingle is a yomap, and coolMulti is an array of yomaps

func (YoMap) IsYoMaps

func (c YoMap) IsYoMaps(s ...interface{}) bool

IsYoMaps returns a bool indicating whether the value of key s within YoMap is of type []YoMap.

Example
// ... see the IsYoMap() example ...//
Output:

func (YoMap) Lacks

func (c YoMap) Lacks(s ...interface{}) bool

Lacks will return a bool indicating whether or not the named key (s) does not exist.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolString`: `this is pretty awesome!`,
			},
		},
	},
}
var path []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `lameString`}
if ym.Lacks(path) {
	fmt.Println("lameString didn't exist")
}
Output:

lameString didn't exist

func (YoMap) Len

func (c YoMap) Len(s ...interface{}) int

Len will return an integer which represents the length (number of named entries) for a given instance of YoMap.

Example
ym := YoMap{
	`coolString`: true,
	`coolBytes`:  []byte(`bytes`),
	`coolBool`:   true,
}
fmt.Printf("YoMap is %d entries long", ym.Len())
Output:

YoMap is 3 entries long

func (YoMap) NilInInterfaces

func (c YoMap) NilInInterfaces(ss ...interface{}) bool

NilInInterfaces returns a bool indicating whether the value is present within a given array interfaces.

Example
// ... see ErrorInInterfaces() example, substituting with nil ... //
Output:

func (YoMap) Ready

func (c YoMap) Ready(s ...interface{}) bool

Ready will return a bool indicating whether the instance of YoMap is initialized (non-nil). Do not confuse "uninitialized" with "empty". A YoMap instance (and maps, for that matter) can have a length of 0 and be non-nil. Use YoMap.Len() if you're interested in the number of entries present within a YoMap instance.

Example
ym := New()
if ym.Ready() {
	fmt.Printf("This YoMap instance is so ready")
}
Output:

This YoMap instance is so ready

func (YoMap) Reset

func (c YoMap) Reset(s ...interface{})

Reset will traverse all keys within a given instance of YoMap; the YoMap.Delete() method is executed for each key. No checks are done beforehand with regards to "nilness", nor are any warnings raised. This leaves the same "space" allocated, which means that if one reuses this object instance, it is faster than running yomap.New() again.

Example
ym := YoMap{
	`coolString`: true,
	`coolBytes`:  []byte(`bytes`),
	`coolBool`:   true,
}
ym.Reset()
fmt.Printf("%d entries remaining in YoMap", ym.Len())
Output:

0 entries remaining in YoMap

func (YoMap) RuneInInterfaces

func (c YoMap) RuneInInterfaces(ss ...interface{}) bool

RuneInInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see the RuneInRunes() example, substituting for type as appropriate ...//
Output:

func (YoMap) RuneInRunes

func (c YoMap) RuneInRunes(ss ...interface{}) bool

RuneInRunes returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []rune{'a', 'b', 'c'},
			},
		},
	},
}

var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.RuneInRunes(coolMulti, 'c') {
	fmt.Println("Desired rune found in array of runes")
}
Output:

Desired rune found in array of runes

func (YoMap) Set

func (c YoMap) Set(s ...interface{})

Set will add the named entry (s) with the value (i) provided. Note this will overwrite anything that already exists by that name.

Example
ym := YoMap{
	`coolString`: `true`,
	`coolBytes`:  []byte(`...someBytes...`),
	`coolBool`:   true,
}
ym.Set([]string{`coolError`}, fmt.Errorf("Coolness limit has been exceeded"))
ym.Set([]string{`coolInt`}, 1)

length := ym.Len()
fmt.Printf("YoMap is %d entries long", length)
Output:

YoMap is 5 entries long

func (YoMap) String

func (c YoMap) String(s ...interface{})

String will simply print out the contents in a human-readable fashion; not intended to be parsed.

Example
ym := YoMap{
	`coolString`: `true`,
	`coolBytes`:  []byte(`...someBytes...`),
	`coolBool`:   true,
}
ym.String()

// This should print the following to Stdout:
//coolString:		true (type:string)
//coolBytes:		[46 46 46 115 111 109 101 66 121 116 101 115 46 46 46] (type:[]uint8)
//coolBool:		true (type:bool)
Output:

func (YoMap) StringInInterfaces

func (c YoMap) StringInInterfaces(ss ...interface{}) bool

StringInInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see StringInStrings() example, substituting for type as appropriate ... //
Output:

func (YoMap) StringInStrings

func (c YoMap) StringInStrings(ss ...interface{}) bool

StringInStrings returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolStrings`: []string{`string1`, `string2`, `string3`},
			},
		},
	},
}

var coolStrings []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolStrings`}

if ym.StringInStrings(coolStrings, `string1`) {
	fmt.Println("Desired string found in array of strings")
}
Output:

Desired string found in array of strings

func (YoMap) TypeOf

func (c YoMap) TypeOf(s ...interface{}) string

TypeOf will return the string form of a key's type of value.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolUnknownThing`: 3.14159,
			},
		},
	},
}

var path []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolUnknownThing`}

fmt.Printf("%s", ym.TypeOf(path))
Output:

float64

func (YoMap) Uint16InInterfaces

func (c YoMap) Uint16InInterfaces(ss ...interface{}) bool

Uint16InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see UintInUints() example, substituting for type as appropriate ... //
Output:

func (YoMap) Uint16InUint16s

func (c YoMap) Uint16InUint16s(ss ...interface{}) bool

Uint16InUint16s returns a bool indicating whether the value is present within a given array of same type.

Example
// ... see UintInUints() example, substituting for type as appropriate ... //
Output:

func (YoMap) Uint32InInterfaces

func (c YoMap) Uint32InInterfaces(ss ...interface{}) bool

Uint32InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see UintInUints() example, substituting for type as appropriate ... //
Output:

func (YoMap) Uint32InUint32s

func (c YoMap) Uint32InUint32s(ss ...interface{}) bool

Uint32InUint32s returns a bool indicating whether the value is present within a given array of same type.

Example
// ... see UintInUints() example, substituting for type as appropriate ... //
Output:

func (YoMap) Uint64InInterfaces

func (c YoMap) Uint64InInterfaces(ss ...interface{}) bool

Uint64InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see IntInInts() example, substituting for type as appropriate ... //
Output:

func (YoMap) Uint64InUint64s

func (c YoMap) Uint64InUint64s(ss ...interface{}) bool

Uint64InUint64s returns a bool indicating whether the value is present within a given array of same type.

Example
// ... see UintInUints() example, substituting for type as appropriate ... //
Output:

func (YoMap) Uint8InInterfaces

func (c YoMap) Uint8InInterfaces(ss ...interface{}) bool

Uint8InInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see UintInUints() example, substituting for type as appropriate ... //
Output:

func (YoMap) Uint8InUint8s

func (c YoMap) Uint8InUint8s(ss ...interface{}) bool

Uint8InUint8s returns a bool indicating whether the value is present within a given array of same type.

Example
// ... see UintInUints() example, substituting for type as appropriate ... //
Output:

func (YoMap) UintInInterfaces

func (c YoMap) UintInInterfaces(ss ...interface{}) bool

UintInInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

func (YoMap) UintInUints

func (c YoMap) UintInUints(ss ...interface{}) bool

UintInUints returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolNumbers`: []uint{1, 2, 3, 4},
			},
		},
	},
}

var coolNumbers []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolNumbers`}

if ym.UintInUints(coolNumbers, uint(4)) {
	fmt.Println("Desired uint found in array of uints")
}
Output:

Desired uint found in array of uints

func (YoMap) UintptrInInterfaces

func (c YoMap) UintptrInInterfaces(ss ...interface{}) bool

UintptrInInterfaces returns a bool indicating whether the value is present within a given array of interfaces.

Example
// ... see the UintptrInUintptrs() example, substituting for type as appropriate ... //
Output:

func (YoMap) UintptrInUintptrs

func (c YoMap) UintptrInUintptrs(ss ...interface{}) bool

UintptrInUintptrs returns a bool indicating whether the value is present within a given array of same type.

Example
ym := YoMap{
	`firstLevel`: YoMap{
		`secondLevel`: YoMap{
			`thirdLevel`: YoMap{
				`coolMulti`: []uintptr{432875, 53234, 18845, 24536},
			},
		},
	},
}

var coolMulti []string = []string{`firstLevel`, `secondLevel`, `thirdLevel`, `coolMulti`}

if ym.UintptrInUintptrs(coolMulti, uintptr(53234)) {
	fmt.Println("Desired uintptr found in array of uintptrs")
}
Output:

Desired uintptr found in array of uintptrs

Jump to

Keyboard shortcuts

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