(in interface{})
| 150 | } |
| 151 | |
| 152 | func InterfaceToInt32(in interface{}) (int32, bool) { |
| 153 | var ok bool |
| 154 | if in, ok = JSONNumberToInt(in); !ok { |
| 155 | return 0, false |
| 156 | } |
| 157 | |
| 158 | switch casted := in.(type) { |
| 159 | case int8: |
| 160 | return int32(casted), true |
| 161 | case int16: |
| 162 | return int32(casted), true |
| 163 | case int32: |
| 164 | return casted, true |
| 165 | case int: |
| 166 | if val := int32(casted); int(val) == casted { |
| 167 | return val, true |
| 168 | } |
| 169 | case int64: |
| 170 | if val := int32(casted); int64(val) == casted { |
| 171 | return val, true |
| 172 | } |
| 173 | } |
| 174 | return 0, false |
| 175 | } |
| 176 | |
| 177 | func InterfaceToInt32Downcast(in interface{}) (int32, bool) { |
| 178 | var ok bool |
no test coverage detected