Tuesday, September 20, 2016

invalid indirect of typedSlice (type interface {})

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())



No comments: