Hello,
Using "
golang.org/x/text/language" I have a map of type map[language.Tag]int. I would like to get the keys present in my map. Why does the following command not work?
...
var x map[language.Tag]int
...
fmt.Println(maps.Keys(x))
The following function does work as expected, so this is easy to work around:
func myKeys(m map[language.Tag]int) []language.Tag {
var res []language.Tag
for key := range m {
res = append(res, key)
}
return res
}
But I wonder now whether it is unwise to use language.Tag for the keys in a map, and why maps.Keys() requires the keys to implement "comparable" in addition to the constraint "M ~map[K]V".
Many thanks,
Jochen