你可以这样做:// if you know it is a first el in []interface{}el := arr[0]// and than you type cast it to []intif arr, ok := el.([]int); ok { fmt.Println(arr[0])}// or if you want to do the same thing for all elements (searching...)for _, el := range arr { if el, ok := el.([]int); ok { // use el as a []int here process(el) }}
索引[]interface{}应该像interfaceSlice[0]例子:a := []interface{}{1, 2, 3, 4, 5}d := []interface{}{a}var b []inte := d[0].([]interface{})for i := range e { b = append(b, e[i].(int))}fmt.Println(b)