vendredi 4 septembre 2015

Is it possible to do something similar to a type switch using reflection?

I need to do different things based on the type of the value being reflected.

value := reflect.ValueOf(someInterface)

I'd like to do something that has the following effect:

if <type of value> == <type1> {
    do something
} else if <type of value> == <type2> {
    do something
}

This is something similar to what a type switch does in go code.





Aucun commentaire:

Enregistrer un commentaire