GetMapKeys returns a slice of keys from a map. This is a generic function that works with any comparable key type and any value type.
(m map[K]V)
| 18 | // GetMapKeys returns a slice of keys from a map. |
| 19 | // This is a generic function that works with any comparable key type and any value type. |
| 20 | func GetMapKeys[K comparable, V any](m map[K]V) []K { |
| 21 | keys := make([]K, 0, len(m)) |
| 22 | for k := range m { |
| 23 | keys = append(keys, k) |
| 24 | } |
| 25 | return keys |
| 26 | } |