NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
``` ~~~ package main type Person struct { name string age int64 sex string } // 公司 type company struct { companyName string companyAddress string } // 员工, 继承了company结构体 type staff struct { name string age int64 sex string company } // interface,多态 type Good interface { totalPrice() int64 goodsInfo() string } type Apple struct { name string quantity int64 price int64 } type Pear struct { name string quantity int64 price int64 } // Tag // omitempty:当值为false, 0, 空指针,空接口,空数组,空切片,空映射,空字符串中的一种时,就会被忽略 type People struct { Name string `json:"name"` Age string `json:"age"` Sex string `json:"sex,omitempty"` } ~~~ ```