jeudi 14 juillet 2022

Get pointer type of a reflect.Type

Assume I only have a reflect.Type t:

fmt.Println(t) //prints lib.Counter

I would like to get pointer type to this type, such that:

fmt.Println(ptrT) //prints *lib.Counter

How can I do this? t can be of any type, not only lib.Counter.

Also, what if I want to do vice versa? Like getting lib.Counter from *lib.Counter?





Aucun commentaire:

Enregistrer un commentaire