(in interface{})
| 88 | } |
| 89 | |
| 90 | func InterfaceToInt16(in interface{}) (int16, bool) { |
| 91 | var ok bool |
| 92 | if in, ok = JSONNumberToInt(in); !ok { |
| 93 | return 0, false |
| 94 | } |
| 95 | |
| 96 | switch casted := in.(type) { |
| 97 | case int8: |
| 98 | return int16(casted), true |
| 99 | case int16: |
| 100 | return casted, true |
| 101 | case int32: |
| 102 | if val := int16(casted); int32(val) == casted { |
| 103 | return val, true |
| 104 | } |
| 105 | case int: |
| 106 | if val := int16(casted); int(val) == casted { |
| 107 | return val, true |
| 108 | } |
| 109 | case int64: |
| 110 | if val := int16(casted); int64(val) == casted { |
| 111 | return val, true |
| 112 | } |
| 113 | } |
| 114 | return 0, false |
| 115 | } |
| 116 | |
| 117 | func InterfaceToInt16Downcast(in interface{}) (int16, bool) { |
| 118 | var ok bool |
nothing calls this directly
no test coverage detected