```go
package main
import "fmt"
func main() {
var p *[]int
var arr []int = []int{1,2}
p=&arr
fmt.Println(p[0]) //报错:invalid operation: p[0] (index of type *[]int)
}
```
而下面的正确
```go
package main
import "fmt"
func main() {
var p *[2]int
var arr [2]int = [2]int{1,2}
p=&arr
fmt.Println(p[0]) //输出:1
}
```
为什么fmt.Println(p[0])报错啊,求指教!!!
有疑问加站长微信联系(非本文作者)