type Personinterface{Name()string}type Studentstruct name func (s Student)Namestringreturn s.namefunc mainvar p Person p =Student:"roc" fmt.Printlnp.Name())//roc}
type TeacherPerson//接口组合Teach()type MyTeacherclasst MyTeacher t)Teach("I am teaching ",t.class)func say_hellop Person)if mok := p.(MyTeacher);//看此Person是否为MyTeacher的实例,如果是再执行if内的内容"hello "m} t TeacherMyTeacher name :"english"//roc.Teach//I am teaching english say_hello//hello roc}