首页 > TAG信息列表 > animalMap

go语言接口的实现

接口可以很好的封装有同一类功能的方法 首先在具体实现里面定义自己的实现,这边定义了2个 type Cat struct{} func (c *Cat) Call() { fmt.Println("miao,miao...") } func (c *Cat) Eat() { fmt.Println("fish") } /////// type Dog struct{} func (d *Dog) Call() { fmt.