github.com/sohaha/zlsgo@v1.7.13-0.20240501141223-10dd1a906f76/zarray/map.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 package zarray 5 6 // Keys creates an array of the map keys 7 func Keys[K comparable, V any](in map[K]V) []K { 8 result := make([]K, 0, len(in)) 9 10 for k := range in { 11 result = append(result, k) 12 } 13 14 return result 15 } 16 17 // Values creates an array of the map values 18 func Values[K comparable, V any](in map[K]V) []V { 19 result := make([]V, 0, len(in)) 20 21 for _, v := range in { 22 result = append(result, v) 23 } 24 25 return result 26 }