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?
import "golang.org/x/exp/maps" ... var x map[language.Tag]int ... fmt.Println(maps.Keys(x)) The error message is "Tag does not implement comparable". Code on the playground: https://go.dev/play/p/dsyEt0ClDBH . 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 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/fc3f94ac-e4ae-4964-8c38-ece6492ccd00n%40googlegroups.com.