Go newbie here. I have two structs, Parent and Child. Child contains Parent as an anonymous field. I want to know how I can pass that struct to a function which is expecting a Parent (and knows nothing about Child). Here's code illustrating what I want to do:
package main
import "fmt"
type Parent struct {
Dad string
}
type Child struct {
Parent
Son string
}
func myfunc(data Parent) {
fmt.Printf("Dad is %s
", data.Dad)
}
func main() {
var data Child
data.Dad = "pappy"
data.Son = "sonny"
myfunc(data)
}
What's the magic declaration of myfunc() to get this to work?