(资料图片)
golang中的多态是通过interface类型实现的
type Person interface { //接口Person规定了方法GetName GetName()}type Student struct { Name string Age int}func (this *Student) GetName() { ()}type Teacher struct { Name string Age int}func (this *Teacher) GetName() { ()}