```go
func main() {
a := make([]int, 10)
for i := 0; i < 10; i++ {
a[i] = i + 6
}
index := array(a, 11)
fmt.Println(index)
}
func array(arr interface{}, d interface{}) int {
arrli := reflect.ValueOf(arr)
for i := 0; i < arrli.Len(); i++ {
v := arrli.Index(i)
if v.Interface() == d {
return i
}
}
return -1
}
```
有疑问加站长微信联系(非本文作者)