Hi everyone
I’m writing a small ORM library. In there I have to set child-models to an array of the parent model generically. I don’t know the types of the models in the library.
What I have:
I have the parent model as type any / interface{}
I have an array of child models as type []any / []interface{}
What I try to do:
I get the reflect.Field of the parent model (works)
I convert the child array to a value with reflect.ValueOf(children)
I want to set the value with field.SetValue()
I get the error reflect.Set: value of type []interface {} is not assignable to type []mod.Person
(Person is my child model in that case)
How could I achieve this?