I'm actually trying some black magic using reflection in golang :P
I got something like this :
var _int int
var _int32 int32
var _int64 int64
var _string string
var nilablesIndex map[int]reflect.Value
var nilables = map[string]reflect.Type {
"int32": reflect.TypeOf(_int32)},
"int64": reflect.TypeOf(_int64)},
"int": reflect.TypeOf(_int)},
"string": reflect.TypeOf(_string)},
}
nilablesIndex[len(m) - 1] = reflect.New(nilables[field.Type.String()][1])
To summarize, I have at this moment a reflect.Value created by reflect.New(nilables[field.Type.String()][1])
That I want is to cast this variable by its original type.
Example : If nilablesIndex[0]
is a reflect.Type int32
, I want to cast it to type int32
.
Is it possible ?
Thank you :)
Aucun commentaire:
Enregistrer un commentaire