I am getting an error like this
reflect.Value.Convert: value of type string cannot be converted to type int
goroutine 6
When I am running this code
param := "string" // type string
ps := fn.In(i) // type int
if !reflect.TypeOf(param).ConvertibleTo(ps) {
fmt.Print("Could not convert parameter.\n") // this is printed
}
convertedParam := reflect.ValueOf(param).Convert(ps)
Can I do this in some way without calling a switch/case?
Aucun commentaire:
Enregistrer un commentaire