[Go] panic: assignment to entry in nil map

通过llama.cpp与羊驼聊天的网页界面- 详解 Serge 的启动使用

 

以上错误出现在给 map 变量赋值的时候。

例如:

type AbMap map[string]string

var abMap AbMap

abMap['a'] = 'b'

 

使用 map 变量需要使用 make 初始化,然后才能赋值。

type AbMap map[string]string

abMap := make(AbMap)

abMap['a'] = 'b'

 

Refer:什么是Golang的Panic

Link:https://www.cnblogs.com/farwish/p/13676086.html

posted on 2020-09-15 22:33  ercom  阅读(1632)  评论(0编辑  收藏  举报