I have a reflect.Type
that contains a double-pointer to a struct. I'd like to be able to remove one level of indirection to have a pointer to the struct. Is this possible? For example, I'd like to do this:
func foo(x interface{}) {
typ := reflect.TypeOf(x)
fmt.Printf("%v", typ) // prints **Foo
realType := typ.PointsTo()
fmt.Printf("%v", typ) // prints *Foo
}
But as far as I can see, this functionality does not exist. There is an Indirect
function that operates on Value
s, but I can't see anything similar that works on Type
s.
Aucun commentaire:
Enregistrer un commentaire