I'm struggling trying to figure out how to "extract" an integer value from a interface that holds a value whose dynamic type is pointer to integer.
You may follow this ready-to-run example in order to fully get the picture of what is problem and my intention.
TD;DR:
For some reason the reflection on a first call to reflect.ValueOf(value)
over an interface whose dynamic type is pointer to integer, it returns a value whose Kind()
results in reflect.Ptr
, when i extract again the "inner" value using reflect.ValueOf(value).Elem()
i get another value whose Kind()
results in reflect.Struct
. I don't even code any struct, but they appears by their own "magically". So golang may not panic but i don't understand what is happening, probably i lack of some information. I would be very thankful with anyone that explaint me what is going on.
This may work for this case, but it doesn't enlight me. I would expect to have an integer value "behind" the pointer. I don't need to access for modification, i only need to get it.
Aucun commentaire:
Enregistrer un commentaire