golang 多索引
If you’re reading this post you’re probably searching on Google how to solve this problem: you’re passing a pointer to a slice
or map
in a function, and when referencing an item with *variable[0]
, you get that error.
如果您正在阅读这篇文章,则可能是在Google上搜索如何解决此问题:您正在向函数中的slice
或map
传递指针,并且在使用*variable[0]
引用项目时,会得到错误。
我该如何解决? (How do I solve it?)
The solution is simple: instead of using
解决方案很简单:代替使用
*variable[0]
use
用
(*variable)[0]