小编Ina*_*Xia的帖子

如何将切片分配给结构中的切片?

type Node struct {
    Stat *Stat
}


type Stat struct {
    StatInfo []string
}
Run Code Online (Sandbox Code Playgroud)

然后

node := new(Node)
node.Stat.Statinfo=strings.Split(somestr," ")
Run Code Online (Sandbox Code Playgroud)

结果是:

恐慌:运行时错误:无效的内存地址或零指针取消引用

go

0
推荐指数
1
解决办法
55
查看次数

标签 统计

go ×1