Documentation
¶
Index ¶
- func Get[K comparable, V any](object map[K]V, key string) (vvv V)
- func Indexes[K comparable, V any](object map[K]V) map[string]V
- func Keys[K comparable, V any](object map[K]V) []K
- func Map[K comparable, V any](object map[K]V, iteratee func(V, K) V) map[K]V
- func MergeMap[K comparable, V any](maps ...map[K]V) map[K]V
- func MustStructToMap[K comparable, V any](structValue any) map[K]V
- func Omit[K comparable, V any](object map[K]V, keys ...K) map[K]V
- func OmitBy[K comparable, V any](object map[K]V, fn func(V, K) bool) map[K]V
- func Pick[K comparable, V any](object map[K]V, keys ...K) map[K]V
- func PickBy[K comparable, V any](object map[K]V, fn func(V, K) bool) map[K]V
- func StructToMap[K comparable, V any](structValue any) (mapValue map[K]V, err error)
- func ToMap(in any, tag ...string) (map[string]any, error)
- func Unique[T comparable](origin []T, keyFn ...func(origin T, index int) string) []T
- func UniqueBy[T comparable](origin []T, keyFn func(origin T, index int) string) []T
- func Values[K comparable, V any](object map[K]V) []V
- func Walk[K comparable, V any](object map[K]V, fn func(V, K, string))
- func WalkByDeepFirst[K comparable, V any](object map[K]V, fn func(V, K, string), parent string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get[K comparable, V any](object map[K]V, key string) (vvv V)
Get returns the value of the key in the object. Support key path
Example:
object.Get(map[string]interface{}{"a": 1}, "a") // 1 object.Get(map[string]interface{}{"a": map[string]interface{}{"b": 2}}, "a.b") // 2
func Indexes ¶ added in v1.0.1
func Indexes[K comparable, V any](object map[K]V) map[string]V
Indexes flattens a nest map into a map with only one level.
func Map ¶
func Map[K comparable, V any](object map[K]V, iteratee func(V, K) V) map[K]V
Map returns a new map with the same keys by iteratee function from the map.
func MergeMap ¶ added in v1.2.11
func MergeMap[K comparable, V any](maps ...map[K]V) map[K]V
MergeMap returns a new map by merging maps.
func MustStructToMap ¶ added in v1.4.5
func MustStructToMap[K comparable, V any](structValue any) map[K]V
MustStructToMap converts struct to map and panics if there is an error
func Omit ¶
func Omit[K comparable, V any](object map[K]V, keys ...K) map[K]V
Omit returns a new map with keys omitted from the map.
func OmitBy ¶
func OmitBy[K comparable, V any](object map[K]V, fn func(V, K) bool) map[K]V
OmitBy returns a new map by omitted function from the map.
func Pick ¶
func Pick[K comparable, V any](object map[K]V, keys ...K) map[K]V
Pick returns a new map with keys picked from the map.
func PickBy ¶
func PickBy[K comparable, V any](object map[K]V, fn func(V, K) bool) map[K]V
PickBy returns a new map by picked function from the map.
func StructToMap ¶ added in v1.4.5
func StructToMap[K comparable, V any](structValue any) (mapValue map[K]V, err error)
StructToMap converts struct to map
func Unique ¶ added in v1.2.3
func Unique[T comparable](origin []T, keyFn ...func(origin T, index int) string) []T
Unique retturns a unique array of objects.
func UniqueBy ¶ added in v1.2.3
func UniqueBy[T comparable](origin []T, keyFn func(origin T, index int) string) []T
UniqueBy returns a unique array of objects by keyFn.
func Values ¶
func Values[K comparable, V any](object map[K]V) []V
Values returns the values of the map.
func Walk ¶ added in v1.0.1
func Walk[K comparable, V any](object map[K]V, fn func(V, K, string))
Walk traverses object by deep first.
func WalkByDeepFirst ¶ added in v1.0.1
func WalkByDeepFirst[K comparable, V any](object map[K]V, fn func(V, K, string), parent string)
WalkByDeepFirst traverses object by deep first.
Types ¶
This section is empty.