注意逗号!!!
func constructor() myStruct {
return myStruct{
a : make([]int,0),
b : make(map[int]int),
}
}
输出结构体某字段的值
type People struct {
Name string
Age int
}
var p People
p.Name
结构体传入接口类型的函数里,怎么获取该结构体的字段值?——断言
func test(a interface){
x := p.(People)
x.Name
}
test(p)