标签:print struct lang package str 组合 type highlight pac
对象和组合
package main import ( "fmt" ) type father struct { name string sex int } type sun struct { father age int } func main() { m:=father{name:"father",sex:11} s:=sun{father:father{name:"son",sex:12},age:14} fmt.Println(s) fmt.Println("name",s.name) fmt.Println("name",m.name) fmt.Println("sex",s.sex) fmt.Println("sex",m.sex) fmt.Println("age",s.age) }
标签:print struct lang package str 组合 type highlight pac
原文地址:http://www.cnblogs.com/peterinblog/p/7837418.html