第一种情况:
``` go
sl:=[]int{1,2,3}
psl:=reflect.SliceHeader(sl)
fmt.Println(psl)
```
报错:cannot convert expression of type []int to type SliceHeader
第二种情况:
``` go
var psl []int
sl:=[]int{1,2,3}
psl=reflect.SliceHeader(sl)
fmt.Println(psl)
```
报错:
cannot convert expression of type []int to type SliceHeader;
cannot use reflect.SliceHeader(sl) (type SliceHeader) as type []int in assignment
初学go,为什么sliceheader类型和slice类型不能互转?
有疑问加站长微信联系(非本文作者)