panic: runtime error: invalid memory address or nil pointer dereference

只可以给索引1和3赋值,因为只有它们分配了内存,才可以赋值,如果我们给索引0赋值,运行的时候,会提示无效内存或者是一个nil指针引用。

解决办法 :我们要先给索引0分配内存,然后再进行赋值修改。

猜你喜欢

转载自blog.csdn.net/weixin_37887248/article/details/86219850