package main import "fmt" type LittleBoy struct { name string age int32 } type Boy struct { name string age int32 } type Person interface { SayName() } func (p Boy) SayName() { fmt.Println(p.name) } func (p LittleBoy) SayName() { fmt.Println(p.name) } func main() { fmt.Println("hello world!") person := LittleBoy{ name: "cyao", age: 18, } ExecSayName(person) } func ExecSayName(person Person) { person2, ok := person.(LittleBoy) if ok { person2.name = "cyao2" } person = person2 person.SayName() }