Golang invalid operation: arr[i] (type *[]int does not support indexing)

Golang invalid operation: arr[i] (type *[]int does not support indexing)

go语言调用数组指针的时候犯了个错,使用了以下方式赋值,结果报错“invalid operation: arr[i] (type *[]int does not support indexing)”
错误做法:

*arr[i]

正确做法:

(*arr)[i]

因为go会把 * arr[i] 当作 * (arr[i])

猜你喜欢

转载自blog.csdn.net/weixin_45760685/article/details/104995468
今日推荐