func decodeSlice(r io.Reader, v reflect.Value) (err error) { switch v.Interface().(type) { case []byte: var result []byte if result, err = read.Binary(r); err == nil { v.SetBytes(result) } default: err = decodeList(r, v) } return }
func decodeArray(r io.Reader, v reflect.Value) (err error) { length := v.Len() switch v.Type().Elem().Kind() { case reflect.Uint8: var result []byte if result, err = read.Binary(r); err == nil { if length == len(result) { for i := range result { v.Index(i).SetUint(uint64(result[i])) } } else { err = fmt.Errorf("%v overflows %T", result, v.Type()) } } default: err = decodeList(r, v) } return }