For example, I have a struct that I take from the outside. I do not know the struct in fields and field values. I want to copy and use the same struct. With reflection I find the fields and types in it. But how do I create this struct in the runtime?
func typeReflection(_person interface{}){
val := reflect.ValueOf(_person)
for i := 0; i < val.Type().NumField(); i++ {
fmt.Println(val.Type().Field(i).Tag.Get("json"))
fmt.Println(val.Field(i))
//How to create same struct
}
Aucun commentaire:
Enregistrer un commentaire