func getIntegerValue()

in datahub/types.go [137:181]


func getIntegerValue(val interface{}) (int64, error) {
	var realval int64
	switch v := val.(type) {
	case int:
		realval = int64(v)
	case int8:
		realval = int64(v)
	case int16:
		realval = int64(v)
	case int32:
		realval = int64(v)
	case int64:
		realval = int64(v)
	case uint:
		realval = int64(v)
	case uint8:
		realval = int64(v)
	case uint16:
		realval = int64(v)
	case uint32:
		realval = int64(v)
	case Bigint:
		realval = int64(v)
	case Integer:
		realval = int64(v)
	case Smallint:
		realval = int64(v)
	case Tinyint:
		realval = int64(v)
	case uint64:
		if v > 9223372036854775807 {
			return 0, fmt.Errorf("Integer type field must be in [-9223372036854775807,9223372036854775807]")
		}
		realval = int64(v)
	case json.Number:
		nval, err := v.Int64()
		if err != nil {
			return 0, err
		}
		realval = int64(nval)
	default:
		return 0, fmt.Errorf("value type[%T] not match field type", val)
	}
	return realval, nil
}