Skip to content

Commit

Permalink
Fix the issue where arrays weren't grown when unmarshalling data from…
Browse files Browse the repository at this point in the history
… server
  • Loading branch information
khaf committed May 30, 2015
1 parent f8c2da2 commit fe4aa75
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions read_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,13 @@ func setValue(f reflect.Value, value interface{}) error {
// BLOBs come back as []byte
theArray := reflect.ValueOf(value)

if f.Kind() == reflect.Slice && f.IsNil() {
f.Set(reflect.MakeSlice(reflect.SliceOf(f.Type().Elem()), theArray.Len(), theArray.Len()))
if f.Kind() == reflect.Slice {
if f.IsNil() {
f.Set(reflect.MakeSlice(reflect.SliceOf(f.Type().Elem()), theArray.Len(), theArray.Len()))
} else if f.Len() < theArray.Len() {
count := theArray.Len() - f.Len()
f = reflect.AppendSlice(f, reflect.MakeSlice(reflect.SliceOf(f.Type().Elem()), count, count))
}
}

for i := 0; i < theArray.Len(); i++ {
Expand Down

0 comments on commit fe4aa75

Please sign in to comment.