Ensure the ptr is pointing to reflect.Slice in ExtractList

This commit is contained in:
Michal Fojtik
2015-01-27 17:43:46 +01:00
parent 60eba74c14
commit ae3f10a397
2 changed files with 6 additions and 2 deletions

View File

@@ -43,6 +43,10 @@ func GetItemsPtr(list Object) (interface{}, error) {
}
switch items.Kind() {
case reflect.Interface, reflect.Ptr:
target := reflect.TypeOf(items.Interface()).Elem()
if target.Kind() != reflect.Slice {
return nil, fmt.Errorf("items: Expected slice, got %s", target.Kind())
}
return items.Interface(), nil
case reflect.Slice:
return items.Addr().Interface(), nil