I want to ensure that the type of map
keys is string
. Key()
method returns Type
and I'm not sure what is the right way to check if it's string
. The only thing came to my mind is:
if v.Type().Key() == reflect.TypeOf("") {
fmt.Print("It is string")
}
Is it the right way?
Aucun commentaire:
Enregistrer un commentaire