gpt4 book ai didi

pointers - 指针 slice 的指针在制作时 panic

转载 作者:数据小太阳 更新时间:2023-10-29 03:38:48 24 4
gpt4 key购买 nike

<分区>

我有以下代码:

var ANIMATIONS *[]*SDL.Animable

....

func main() {
*ANIMATIONS = make([]*SDL.Animable, 0, 100)

但是运行的时候会出现panic。正确的初始化方法是什么?

错误:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x4afe3a]

goroutine 1 [running, locked to thread]:
main.main()

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com