vendredi 5 janvier 2018

How to set a nil struct to its zero value using reflection in Go?

How can I set a nil struct to its zero value using reflection? I already tried the following:

v.Interface() = reflect.Zero(f.Type)

Where v is the reflect.Value and f is the reflect.StructField of a struct field.





Aucun commentaire:

Enregistrer un commentaire