Documentation
¶
Index ¶
- func CopyTo[Map ~map[K]V, K comparable, V any](src Map, dist Map)
- func DeepReplaceValue(dict map[string]any, oldStr, newStr string) map[string]any
- func DeepReplaceValueUnsafe(dict any, oldStr, newStr string) any
- func GetBool(dict map[string]any, key string) bool
- func GetInt(dict map[string]any, key string) int
- func GetInt32(dict map[string]any, key string) int32
- func GetInt64(dict map[string]any, key string) int64
- func GetKVMap[V any](dict map[string]any, key string) map[string]V
- func GetKVMapAny(dict map[string]any, key string) map[string]any
- func GetOrDefaultBool(dict map[string]any, key string, defaultValue bool) bool
- func GetOrDefaultInt(dict map[string]any, key string, defaultValue int) int
- func GetOrDefaultInt32(dict map[string]any, key string, defaultValue int32) int32
- func GetOrDefaultInt64(dict map[string]any, key string, defaultValue int64) int64
- func GetOrDefaultString(dict map[string]any, key string, defaultValue string) string
- func GetOrDefaultStringsBySplit(dict map[string]any, key string, sep string, defaultValue []string) []string
- func GetString(dict map[string]any, key string) string
- func GetStringsBySplit(dict map[string]any, key string, sep string) []string
- func Keys[Map ~map[K]V, K comparable, V any](dict Map) []K
- func Populate(dict map[string]any, output any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyTo ¶ added in v0.4.28
func CopyTo[Map ~map[K]V, K comparable, V any](src Map, dist Map)
将源字典中的所有键值对复制到目标字典中。
入参:
- src: 源字典。
- dist: 目标字典。
func DeepReplaceValue ¶ added in v0.4.27
在字典中递归地替换指定的字符串的值。 注意该函数会修改原始的字典。
入参:
- dict: 字典。
- oldStr:需要替换的字符串。
- newStr:替换后的字符串。
出参:
- dict: 替换后的字典。
func DeepReplaceValueUnsafe ¶ added in v0.4.27
与 DeepReplaceValue 类似,但入参类型为 `any`。
func GetInt ¶ added in v0.4.4
以整数形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
出参:
- 字典中键对应的值。如果指定键不存在、或者值的类型不是整数,则返回 0。
func GetInt32 ¶
以 32 位整数形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
出参:
- 字典中键对应的值。如果指定键不存在、或者值的类型不是 32 位整数,则返回 0。
func GetInt64 ¶
以 64 位整数形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
出参:
- 字典中键对应的值。如果指定键不存在、或者值的类型不是 64 位整数,则返回 0。
func GetKVMap ¶
以 `map[string]V` 形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
出参:
- 字典中键对应的 `map[string]V` 对象。
func GetKVMapAny ¶
以 `map[string]any` 形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
出参:
- 字典中键对应的 `map[string]any` 对象。
func GetOrDefaultBool ¶
以布尔形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
- defaultValue: 默认值。
出参:
- 字典中键对应的值。如果指定键不存在、或者值的类型不是布尔,则返回默认值。
func GetOrDefaultInt ¶ added in v0.4.4
以整数形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
- defaultValue: 默认值。
出参:
- 字典中键对应的值。如果指定键不存在、值的类型不是整数、或者值为零值,则返回默认值。
func GetOrDefaultInt32 ¶
以 32 位整数形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
- defaultValue: 默认值。
出参:
- 字典中键对应的值。如果指定键不存在、值的类型不是 32 位整数、或者值为零值,则返回默认值。
func GetOrDefaultInt64 ¶
以 64 位整数形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
- defaultValue: 默认值。
出参:
- 字典中键对应的值。如果指定键不存在、值的类型不是 64 位整数、或者值为零值,则返回默认值。
func GetOrDefaultString ¶
以字符串形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
- defaultValue: 默认值。
出参:
- 字典中键对应的值。如果指定键不存在、值的类型不是字符串、或者值为零值,则返回默认值。
func GetOrDefaultStringsBySplit ¶ added in v0.4.28
func GetOrDefaultStringsBySplit(dict map[string]any, key string, sep string, defaultValue []string) []string
以字符串形式从字典中获取指定键的值,并按指定分隔符拆分。
入参:
- dict: 字典。
- key: 键。
- defaultValue: 默认值。
出参:
- 字典中键对应的值。如果指定键不存在、值的类型不是字符串、或者值为零值,则返回默认值。
func GetString ¶
以字符串形式从字典中获取指定键的值。
入参:
- dict: 字典。
- key: 键。
出参:
- 字典中键对应的值。如果指定键不存在、或者值的类型不是字符串,则返回空字符串。
func GetStringsBySplit ¶ added in v0.4.28
以字符串形式从字典中获取指定键的值,并按指定分隔符拆分。
入参:
- dict: 字典。
- key: 键。
出参:
- 字典中键对应的值。如果指定键不存在、或者值的类型不是字符串,则返回空字符串切片。
func Keys ¶ added in v0.4.28
func Keys[Map ~map[K]V, K comparable, V any](dict Map) []K
获取字典中的所有键组成的切片。
入参:
- dict: 字典。
出参:
- keys: 字典中的所有键组成的切片。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.