我需要向这个结构添加切片类型。
type Example struct {
text []string
}
func main() {
var arr = []Example {
{{"a", "b", "c"}},
}
fmt.Println(arr)
}
然后我得到
prog.go:11: missing type in composite literal
[process exited with non-zero status]
所以指定复合文字
var arr = []Example {
{Example{"a", "b", "c"}},
但仍然收到此错误:
cannot use "a" (type string) as type []string in field value
http://play.golang.org/p/XKv1uhgUId
我该如何解决?如何构造包含数组(切片)类型的结构?