父类的方法可以被子类继承使用
package main import ( "fmt" ) //父类 type Person05 struct { name string sex string age int } func (p Person05) printInfo() { fmt.Printf("名称:%s, 性别:%s, 年龄:%d\n", p.name, p.sex, p.age) } //子类 type Student05 struct { Person05 id int } func main() { var s Student05 = Student05{Person05{"yy", "男", 18}, 1} //使用父类方法 s.printInfo() }