I wrote the code:
switch v.(type) {
case []interface{}:
fmt.Println(reflect.TypeOf(v))
for index, element := range v {
fmt.Println("Inside for")
}
default:
fmt.Println("I don't know how to handle this.")
}
Now, my reflect.TypeOf(v)
outputs the type as []interface {}
. But, I'm not able to iterate over the array of interfaces. I encounter the error:cannot range over v (type interface {})
. Could someone please explain me why ? Also, what's the workaround ?