Skip to content

Commit

Permalink
Remove special unmarshaling support for []byte
Browse files Browse the repository at this point in the history
The fact that I'm unsure how it should work is a dead giveaway that it's
not needed right now. Adding by removing :)
  • Loading branch information
vcschapp committed Jul 18, 2021
1 parent 9ffa479 commit e82d5b6
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import (
// uint, uint8, uint16, uint32, uint64
// float32, float64
// interface{}
// []byte
// Any map, struct, slice, or array type
//
// A struct field targeting interface{} or any map, struct, slice, or
Expand Down Expand Up @@ -219,7 +218,6 @@ type decodeFunc func(*decodeState) error

var (
resultType = reflect.TypeOf(Result{})
byteSliceType = reflect.TypeOf([]byte{})
textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
jsonUnmarshalerType = reflect.TypeOf((*json.Unmarshaler)(nil)).Elem()
)
Expand Down Expand Up @@ -425,12 +423,7 @@ func selStructRowColDecodeFuncByType(colType reflect.Type) (decodeFunc, error) {
return decodeColToFloat, nil
case reflect.Bool:
return decodeColToBool, nil
case reflect.Slice:
if colType == byteSliceType {
return decodeColToByteSlice, nil
}
fallthrough
case reflect.Interface, reflect.Struct, reflect.Map, reflect.Array:
case reflect.Interface, reflect.Struct, reflect.Map, reflect.Slice, reflect.Array:
return decodeColAsJSON, nil
default:
return nil, errors.New("unsupported struct field type")
Expand All @@ -447,11 +440,6 @@ func decodeColToString(s *decodeState) error {
return nil
}

func decodeColToByteSlice(s *decodeState) error {
s.dst.SetBytes([]byte(s.col().Value))
return nil
}

func decodeColToInt(s *decodeState) error {
src := s.col().Value
n, err := strconv.ParseInt(src, 10, 64)
Expand Down

0 comments on commit e82d5b6

Please sign in to comment.