From e82d5b65786ae6f5cc6740b982b761c8b874680f Mon Sep 17 00:00:00 2001 From: Victor Schappert Date: Sat, 17 Jul 2021 22:14:52 -0700 Subject: [PATCH] Remove special unmarshaling support for []byte The fact that I'm unsure how it should work is a dead giveaway that it's not needed right now. Adding by removing :) --- unmarshal.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/unmarshal.go b/unmarshal.go index 40e8a6d..d9d5f40 100644 --- a/unmarshal.go +++ b/unmarshal.go @@ -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 @@ -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() ) @@ -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") @@ -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)