Following code has Holder specified as of interface
type.
What changes can be done to the Holder object so it receives any kind with reference type, so if any changes to the value object, it gets reflected on the main.
type Holder struct {
Body interface{}
}
type Value struct {
Input int
Result int
}
func main() {
value := Value{Input: 5}
holder := Holder{Body: value}
fmt.Println(value) // {5 0}
modify(holder)
fmt.Println(value) // {5 0} should display {5 10}
}
func modify(holder Holder) {
var value Value = holder.Body.(Value)
value.Result = 2 * value.Input
}