比如 a.go:
```
package be
type Animail interface {
Say()
Run()
}
```
b.go:
```
package model
import (
"fmt"
)
type Dog struct {
}
type Cat struct {
}
func (dog Dog) Say(){
fmt.Print("狗")
}
func (cat Cat) Say(){
fmt.Println("猫")
}
```
b.go中的 Cat 该怎么实现a.go中定义的接口呢
就是我b.go这那么写的吗?但是并不对啊
```
var an be.Animail
an = new(model.Cat)
```
这段代码是报错的,提示:
```
Cannot use new(model.Cat) (type *model.Cat) as type be.Animail in assignment less... (⌘F1)
Reports incompatible types in binary and unary expressions.
```
#2
更多评论