ToInt64 interface to int64
(value interface{})
| 172 | |
| 173 | // ToInt64 interface to int64 |
| 174 | func ToInt64(value interface{}) (d int64) { |
| 175 | val := reflect.ValueOf(value) |
| 176 | switch value.(type) { |
| 177 | case int, int8, int16, int32, int64: |
| 178 | d = val.Int() |
| 179 | case uint, uint8, uint16, uint32, uint64: |
| 180 | d = int64(val.Uint()) |
| 181 | default: |
| 182 | panic(fmt.Errorf("ToInt64 needs numeric type, not `%T`", value)) |
| 183 | } |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | type argInt []int |
| 188 |