Documentation
¶
Overview ¶
Package mapx provides utility functions for working with Go maps.
Key features:
- Map key extraction and manipulation
- Map merging and cloning
- Type-safe map operations
Usage:
keys := mapx.Keys(myMap) merged := mapx.Merge(map1, map2)
Index ¶
- Variables
- func Copy(props map[string]any) map[string]any
- func Count(props map[string]any) int
- func Get(props map[string]any, key string) (any, bool)
- func GetAnyDefault(props map[string]any, key string, defaultValue any) any
- func GetAnySlice(props map[string]any, key string) ([]any, bool)
- func GetAnySliceDefault(props map[string]any, key string, defaultValue []any) []any
- func GetBool(props map[string]any, key string) (bool, bool)
- func GetBoolDefault(props map[string]any, key string, defaultValue bool) bool
- func GetFloat64(props map[string]any, key string) (float64, bool)
- func GetFloat64Default(props map[string]any, key string, defaultValue float64) float64
- func GetInt(props map[string]any, key string) (int, bool)
- func GetIntDefault(props map[string]any, key string, defaultValue int) int
- func GetMap(props map[string]any, key string) (map[string]any, bool)
- func GetMapDefault(props map[string]any, key string, defaultValue map[string]any) map[string]any
- func GetString(props map[string]any, key string) (string, bool)
- func GetStringDefault(props map[string]any, key, defaultValue string) string
- func GetStrings(props map[string]any, key string) ([]string, bool)
- func GetStringsDefault(props map[string]any, key string, defaultValue []string) []string
- func Has(props map[string]any, key string) bool
- func Keys(input any) []string
- func Merge(props1, props2 map[string]any) map[string]any
- func Set(props map[string]any, key string, value any)
- func ToGeneric(input any) (map[any]any, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInputNotMap = errors.New("input is not a map type")
ErrInputNotMap indicates that the provided input is not of map type.
Functions ¶
func GetAnyDefault ¶
GetAnyDefault returns an any property or default value
func GetAnySlice ¶
GetAnySlice safely gets a []any property from the properties map
func GetAnySliceDefault ¶
GetAnySliceDefault returns a []any property or default value
func GetBoolDefault ¶
GetBoolDefault returns a bool property or default value
func GetFloat64 ¶
GetFloat64 safely gets a float64 property from the properties map
func GetFloat64Default ¶
GetFloat64Default returns a float64 property or default value
func GetIntDefault ¶
GetIntDefault returns an int property or default value
func GetMapDefault ¶
GetMapDefault returns a map[string]any property or default value
func GetStringDefault ¶
GetStringDefault returns a string property or default value
func GetStrings ¶
GetStrings safely gets a []string property from the properties map
func GetStringsDefault ¶
GetStringsDefault returns a []string property or default value
Types ¶
This section is empty.