invalid indirect of typedSlice (type interface {})
You can't dereference typedSlice, because it's an interface{}. You would have to extract the pointer with a type assertion
realSlice := *typedSlice.(*[]Demo)
cannot range over typedSlice (type interface {})
Again, since typedSlice is an interface{}, you can't range over it. If you want to range over the values you need to use a type assertion, or iterate manually via reflect:
for i := 0; i < o.Elem().Len(); i++ {
ret = append(ret, o.Elem().Index(i).Interface())
}
Reference:
http://stackoverflow.com/questions/34163174/cant-use-range-on-slice-made-with-reflect-then-passed-json-unmarshal
No comments:
Post a Comment