diff --git a/cache/interface.go b/cache/cache.go similarity index 100% rename from cache/interface.go rename to cache/cache.go diff --git a/helper/maps/map.go b/helper/maps/map.go index d11f2a4..f4c2016 100644 --- a/helper/maps/map.go +++ b/helper/maps/map.go @@ -1,6 +1,8 @@ package maps -import "encoding/json" +import ( + "encoding/json" +) func StrAnyMapToStruct[T any, M any](m M) (r T, err error) { str, err := json.Marshal(m) @@ -54,6 +56,17 @@ func IsExists[K comparable, V any](m map[K]V, k K) bool { return ok } +func Keys[K comparable, V any](m map[K]V) []K { + return FilterToSlice(m, func(k K, v V) (K, bool) { + return k, true + }) +} +func Values[K comparable, V any](m map[K]V) []V { + return FilterToSlice(m, func(k K, v V) (V, bool) { + return v, true + }) +} + func Reduce[T, V any, K comparable](m map[K]V, fn func(K, V, T) T, r T) T { for k, v := range m { r = fn(k, v, r)