package a type Animal interface { call() } type Dog struct { } type Cat struct { } func (dog Dog) call() { println("我是狗,狗叫") } func (cat Cat) call() { println("我是猫,猫叫") } func main() { println("hello") var animal Animal animal = new(Dog) animal.call() }
标签:func,继承,多态,Dog,println,call,animal,go,type From: https://www.cnblogs.com/wangweiip/p/17118602.html