Documentation ¶
Index ¶
- func IntKeys(m interface{}) (keys []int64)
- func IntValues(m interface{}) (values []int64)
- func MapKeys(m interface{}) (keys interface{})
- func MapValues(m interface{}) (values interface{})
- func MergeMaps(maps ...interface{}) interface{}
- func MergeMapsTo(dst interface{}, others ...interface{}) interface{}
- func StringKeys(m interface{}) (keys []string)
- func StringValues(m interface{}) (values []string)
- type Map
- func (p Map) Get(key string) (value interface{}, exists bool)
- func (p Map) GetBool(key string) bool
- func (p Map) GetBytes(key string) []byte
- func (p Map) GetDuration(key string) time.Duration
- func (p Map) GetFloat64(key string) float64
- func (p Map) GetInt(key string) int
- func (p Map) GetInt32(key string) int32
- func (p Map) GetInt32s(key string) []int32
- func (p Map) GetInt64(key string) int64
- func (p Map) GetInt64s(key string) []int64
- func (p Map) GetMap(key string) Map
- func (p Map) GetSlice(key string) []interface{}
- func (p Map) GetString(key string) string
- func (p Map) GetStrings(key string) []string
- func (p Map) GetStrstrMap(key string) map[string]string
- func (p Map) GetTime(key string) time.Time
- func (p Map) Iterate(fn func(k string, v interface{}) int)
- func (p Map) MustGet(key string) interface{}
- func (p *Map) Set(key string, value interface{})
- type SafeMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntKeys ¶
func IntKeys(m interface{}) (keys []int64)
IntKeys returns a int64 slice containing all the keys present in the map, in unspecified order. It panics if m's kind is not reflect.Map or the key's type is not integer. It returns an empty slice if m is a nil map.
func IntValues ¶
func IntValues(m interface{}) (values []int64)
IntValues returns a int64 slice containing all the values present in the map, in unspecified order. It panics if m's kind is not reflect.Map or the value's type is not integer. It returns an empty slice if m is a nil map.
func MapKeys ¶
func MapKeys(m interface{}) (keys interface{})
MapKeys returns a slice containing all the keys present in the map, in unspecified order. It panics if m's kind is not reflect.Map. It returns an emtpy slice if m is a nil map.
func MapValues ¶
func MapValues(m interface{}) (values interface{})
MapValues returns a slice containing all the values present in the map, in unspecified order. It panics if m's kind is not reflect.Map. It returns an empty slice if m is a nil map.
func MergeMaps ¶
func MergeMaps(maps ...interface{}) interface{}
MergeMaps returns a new map containing all key values present in maps. It panics if given zero param. It panics if given param which is not a map, or different map types. It returns an empty map if all params are nil or empty.
func MergeMapsTo ¶
func MergeMapsTo(dst interface{}, others ...interface{}) interface{}
MergeMapsTo adds key values present in others to the dst map. It panics if dst is nil or not a map, or any param in others is not a map, or they are different map types. If dst is a nil map, it creates a new map and returns it.
func StringKeys ¶
func StringKeys(m interface{}) (keys []string)
StringKeys returns a string slice containing all the keys present in the map, in unspecified order. It panics if m's kind is not reflect.Map or the key's kind is not string. It returns an empty slice if m is a nil map.
func StringValues ¶
func StringValues(m interface{}) (values []string)
StringValues returns a string slice containing all the values present in the map, in unspecified order. It panics if m's kind is not reflect.Map or the value's kind is not string. It returns an empty slice if m is a nil map.
Types ¶
type Map ¶
type Map map[string]interface{}
Map is a map of string key and interface{} value. It provides many useful methods to manipulate map[string]interface{}.
func (Map) Get ¶
Get returns the value for the given key, ie: (value, true). If the value does not exist it returns (nil, false)
func (Map) GetDuration ¶
GetDuration returns the value associated with the key as a duration.
func (Map) GetFloat64 ¶
GetFloat64 returns the value associated with the key as a float64.
func (Map) GetMap ¶
GetMap returns the value associated with the key as a Map (map[string]interface{}).
func (Map) GetSlice ¶
GetSlice returns the value associated with the key as []interface{}. It returns nil if key does not present in Map or the value's type is not []interface{}.
func (Map) GetStrings ¶
GetStrings returns the value associated with the key as a slice of strings.
func (Map) GetStrstrMap ¶
GetStrstrMap returns the value associated with the key as a map of (map[string]string).
func (Map) Iterate ¶
Iterate iterates the map in unspecified order, the given function fn will be called for each key value pair. The iteration can be aborted by returning a non-zero value from fn.