Given an interface that returns a slice of pointer types but wrapped as an interface type. Is it possible to modify the values?
type Base interface {
Do()
}
type Meta interface {
Base
Children() []Base
}
type A struct {
}
func (a *A) Do() {
}
type B struct {
children []Base
}
func (b *B) Children() []Base {
return b.children
}
If the code is initialized in the following way:
a := &A{}
b := &B{children: []Base{a}}
would it be possible to overwrite the values at B.children
just with the values returned after calling b.Children()
and the use of reflect? Or would that not be possible?