I want to write a function to get all keys from a map as a slice of string which key type is string and the value could be any other type.
Like this but can have any kind of map[string]... as input.
func mapLowCaseKeys(v map[string]string) []string {
keys := make([]string, len(v))
i := 0
for key := range v {
keys[i] = strings.ToLower(key)
i++
}
return keys
}
Actually I want achive Object.keys()
in Javascript.
I've tried use map[string]interface{}
as the function's paramter type but it can't just pass any specific map to that function, is this possible in golang?