Go 多态 如何建表啊?
type Animal interface {
Sleep()
Age() int
Type() string
}
type Cat struct {
MaxAge int
Owner string
}
func (this *Cat) Sleep() {
fmt.Println("Cat need sleep")
}
func (this *Cat) Age() int {
return this.MaxAge
}
func (this *Cat) Type() string {
return this.Owner
}
/*=======================================================*/
type Dog struct {
MaxAge int
}
func (this *Dog) Sleep() {
fmt.Println("Dog need sleep")
}
func (this *Dog) Age() int {
return this.MaxAge
}
func (this *Dog) Type() string {
return "Dog"
}这我如何建表啊?
以前用C# 有 Animal, Dog, Cat 3个表 而且MaxAge是抽象类的的字段。
Go 只能建Dog, Cat 两个表 各自包含着MaxAge吗?
...全文
相关推荐
golang GO语言开发工具
golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具golang GO语言开发工具
Go-go-selfupdate-使Golang应用程序能够自我更新
go-selfupdate - 使Golang应用程序能够自我更新
Go-Tao一个用golang编写的异步TCP框架
Tao一个用golang编写的异步TCP框架
Jni-Golang:java调用golang(通过Go1.5共享库)
吉尼·高朗(Jni-Golang) java调用golang(通过Go1.5共享库)
Go-log一个基于Golang的日志模块
log 一个基于Golang的日志模块,该日志模块为标准库log的一个扩展实现。有Debug、Info、Notice、Warn、Error、Panic、Fatal共7个级别的日志。


