package main import "fmt" type animal interface { move() eat(string) } type cat struct { name string feet int8 } type chicken struct { feet int8 } func (c cat) move() { fmt.Printf("走 %s", c.name) } func (c cat) eat(food string) { fmt.Printf("吃鱼i %s", food) } func (c chicken) move() { fmt.Println("激动") } func (c chicken) eat() { fmt.Println("chidoamx") } func main() { var aa animal bc := cat{ name: "李白", feet: 3, } aa = bc aa.eat("小黄鸭") aa.move() }
标签:aa,实现,fmt,move,接口,func,eat From: https://www.cnblogs.com/xiaobaixuecheng101/p/17235872.html