jeudi 4 janvier 2018

How to obtain pointer from reflect.Value in Go?

As far as I know methods with pointer receivers only implement interfaces for pointers. I want to utilize the encoding.TextMarshaler interface which must be implmented with a pointer. How can I therefore obtain a pointer using reflection.

The following does not work because as mentionend a value does not implement the interface:

v.Interface().(encoding.TextUnmarshaler)





Aucun commentaire:

Enregistrer un commentaire