overwrite initiliazed slice as empty slice

This commit is contained in:
İlker Göktuğ Öztürk 2015-07-17 15:47:11 +03:00
parent 5663048f13
commit 77666f6309

View File

@ -30,7 +30,9 @@ func Query(scope *Scope) {
if kind := dest.Kind(); kind == reflect.Slice { if kind := dest.Kind(); kind == reflect.Slice {
isSlice = true isSlice = true
destType = dest.Type().Elem() destType = dest.Type().Elem()
dest.Set(reflect.Indirect(reflect.New(reflect.SliceOf(destType)))) if !dest.IsNil() {
dest.Set(reflect.MakeSlice(reflect.Indirect(reflect.New(reflect.SliceOf(destType))).Type(), 0, 0))
}
if destType.Kind() == reflect.Ptr { if destType.Kind() == reflect.Ptr {
isPtr = true isPtr = true