lundi 18 juin 2018

Golang reflect to test if its a string

Whats wrong with my code? Im trying to test if a value coming from GJson library is a string in the quickest and simplest way possible ( I dont want to use a switch type assertion ).

if reflect.TypeOf(gjson.Get(input, "name").Value()) != "string" {
    return "Not a string!"  
}

Thanks!





Aucun commentaire:

Enregistrer un commentaire