Documentation ¶
Index ¶
- func GetTyped[T any](m map[string]any, key string) T
- 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) GetFloat(key string) float64
- func (p Map) GetInt(key string) int64
- func (p Map) GetInt32s(key string) []int32
- 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) GetStringMap(key string) map[string]string
- func (p Map) GetStrings(key string) []string
- func (p Map) GetTime(key string) time.Time
- func (p Map) Iterate(fn func(k string, v interface{}) int)
- func (p Map) MarshalJSON() ([]byte, error)
- func (p Map) MarshalJSONPretty() ([]byte, error)
- func (p Map) MustGet(key string) interface{}
- func (p *Map) Set(key string, value interface{})
- func (p *Map) UnmarshalJSON(data []byte) error
- type SafeMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Map ¶
type Map map[string]interface{}
Map is a map of string key and interface{} value. It provides many useful methods to work with 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) 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 a slice. It returns nil if key does not present in Map or the value's type is not a slice.
func (Map) GetStringMap ¶
GetStringMap returns the value associated with the key as a map of (map[string]string).
func (Map) GetStrings ¶
GetStrings returns the value associated with the key as a slice of strings.
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.
func (Map) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Map) MarshalJSONPretty ¶
MarshalJSONPretty returns its marshaled data as `[]byte` with indentation using two spaces.
func (*Map) Set ¶
Set is used to store a new key/value pair exclusively in the map. It also lazily initializes the map if it was not used previously.
func (*Map) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.