(typ reflect.Type)
| 56 | } |
| 57 | |
| 58 | func _getDecoder(typ reflect.Type) decoderFunc { |
| 59 | kind := typ.Kind() |
| 60 | |
| 61 | if kind == reflect.Ptr { |
| 62 | if _, ok := typeDecMap.Load(typ.Elem()); ok { |
| 63 | return ptrValueDecoder(typ) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | if typ.Implements(customDecoderType) { |
| 68 | return nilAwareDecoder(typ, decodeCustomValue) |
| 69 | } |
| 70 | if typ.Implements(unmarshalerType) { |
| 71 | return nilAwareDecoder(typ, unmarshalValue) |
| 72 | } |
| 73 | if typ.Implements(binaryUnmarshalerType) { |
| 74 | return nilAwareDecoder(typ, unmarshalBinaryValue) |
| 75 | } |
| 76 | if typ.Implements(textUnmarshalerType) { |
| 77 | return nilAwareDecoder(typ, unmarshalTextValue) |
| 78 | } |
| 79 | |
| 80 | // Addressable struct field value. |
| 81 | if kind != reflect.Ptr { |
| 82 | ptr := reflect.PtrTo(typ) |
| 83 | if ptr.Implements(customDecoderType) { |
| 84 | return addrDecoder(nilAwareDecoder(typ, decodeCustomValue)) |
| 85 | } |
| 86 | if ptr.Implements(unmarshalerType) { |
| 87 | return addrDecoder(nilAwareDecoder(typ, unmarshalValue)) |
| 88 | } |
| 89 | if ptr.Implements(binaryUnmarshalerType) { |
| 90 | return addrDecoder(nilAwareDecoder(typ, unmarshalBinaryValue)) |
| 91 | } |
| 92 | if ptr.Implements(textUnmarshalerType) { |
| 93 | return addrDecoder(nilAwareDecoder(typ, unmarshalTextValue)) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | switch kind { |
| 98 | case reflect.Ptr: |
| 99 | return ptrValueDecoder(typ) |
| 100 | case reflect.Slice: |
| 101 | elem := typ.Elem() |
| 102 | if elem.Kind() == reflect.Uint8 { |
| 103 | return decodeBytesValue |
| 104 | } |
| 105 | if elem == stringType { |
| 106 | return decodeStringSliceValue |
| 107 | } |
| 108 | case reflect.Array: |
| 109 | if typ.Elem().Kind() == reflect.Uint8 { |
| 110 | return decodeByteArrayValue |
| 111 | } |
| 112 | case reflect.Map: |
| 113 | if typ.Key() == stringType { |
| 114 | switch typ.Elem() { |
| 115 | case stringType: |
no test coverage detected
searching dependent graphs…