// ToInt get int from value, if passed value is empty string, result will be 0
765940
func ToInt(value interface{}) int64 {
	if result := ToString(value); result == "" {
		return 0
	} else if i, err := strconv.ParseInt(result, 10, 64); err == nil {
		return i
	} else {
		panic("failed to parse int: " + result)
	}
}
1140228
func Int(name string, value int, usage string) *int {
	return CommandLine.Int(name, value, usage)
}
928009
func (ns *Namespace) ToInt(v interface{}) (int, error) {
	v = convertTemplateToString(v)
	return _cast.ToIntE(v)
}
1369026
func (context *BaseContext) GetInt(
	key string, defaultValue ...int) int {
	if value, ok := context.userData[key]; ok {
		if value, ok := value.(int); ok {
			return value
		}
	}
	if len(defaultValue) > 0 {
		return defaultValue[0]
	}
	return 0
}
1270114
func (c *client) Int(key string, fallback int) int {
	if i, err := strconv.Atoi(c.Getenv(key)); err == nil {
		return i
	}

	return fallback
}
383662
func Int(args []string, index int, def int) (int, error) {
	if len(args) <= index {
		return def, nil
	}

	return strconv.Atoi(args[index])
}
1182241
func (f *Queries) Int(key string) (int, error) {
	s, err := f.String(key)
	if err != nil {
		return 0, err
	}
	return strconv.Atoi(s)
}
293641
func Int() gopter.Gen {
	return Int64Range(math.MinInt32, math.MaxInt32).
		Map(int64ToInt).
		WithShrinker(IntShrinker)
}
644339
func tryToInt(v reflect.Value) (int, error) {
	if v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface {
		v = v.Elem()
	}
	switch v.Kind() {
	case reflect.Float64, reflect.Float32:
		return int(v.Float()), nil
	case reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8, reflect.Int:
		return int(v.Int()), nil
	case reflect.Bool:
		if v.Bool() {
			return 1, nil
		}
		return 0, nil
	case reflect.String:
		s := v.String()
		var i int64
		var err error
		if strings.HasPrefix(s, "0x") {
			i, err = strconv.ParseInt(s, 16, 64)
		} else {
			i, err = strconv.ParseInt(s, 10, 64)
		}
		if err == nil {
			return int(i), nil
		}
	}
	return 0, errors.New("couldn't convert to integer")
}
204706
func GetInt(key string) (int, error) {
	value, err := Get(key)
	if err != nil {
		return 0, err
	}
	if v, ok := value.(int); ok {
		return v, nil
	} else if v, ok := value.(string); ok {
		if i, err := strconv.ParseInt(v, 10, 64); err == nil {
			return int(i), nil
		}
	} else if v, err := GetFloat(key); err == nil {
		if float64(int(v)) == v {
			return int(v), nil
		}
	}
	return 0, &InvalidValue{key, "int"}
}
377063
func ValueToInt(val Value) (int, bool) {
	iv, ok := ValueToInt64(val)
	return int(iv), ok
}
757402
func (c *Cell) Int() (int, error) {
	f, err := strconv.ParseFloat(c.Value, 64)
	if err != nil {
		return -1, err
	}
	return int(f), nil
}
272461
func (a Adder) Int(x int, s ...string) {
	a(float64(x), s...)
}
1063160
func (p *Params) Int(key string) (int, error) {
	return strconv.Atoi(p.Get(key))
}
831481
func Int(input interface{}) (output int64, err error) {

	switch castValue := input.(type) {
	case Inter:
		output = castValue.Int()
		return
	case string:
		output, err = strconv.ParseInt(castValue, 10, 64)
		return
	case []byte:
		output, err = strconv.ParseInt(string(castValue), 10, 64)
		return
	case int:
		output = int64(castValue)
		return
	case int8:
		output = int64(castValue)
		return
	case int16:
		output = int64(castValue)
		return
	case int32:
		output = int64(castValue)
		return
	case int64:
		output = int64(castValue)
		return
	case uint:
		output = int64(castValue)
		return
	case uint8:
		output = int64(castValue)
		return
	case uint16:
		output = int64(castValue)
		return
	case uint32:
		output = int64(castValue)
		return
	case uint64:
		output = int64(castValue)
		return
	case float32:
		output = int64(castValue)
		return
	case float64:
		output = int64(castValue)
		return
	case bool:
		output = int64(0)
		if castValue {
			output = int64(1)
		}
		return
	case nil:
		output = int64(0)
		return
	default:
		err = NewCastError("Could not convert to int")
	}
	return
}
807568
func (dec *Decoder) Int(v *int) error {
	err := dec.decodeInt(v)
	if err != nil {
		return err
	}
	dec.called |= 1
	return nil
}
126913
func (j *JsonQuery) Int(s ...string) (int, error) {
	val, err := rquery(j.blob, s...)
	if err != nil {
		return 0, err
	}
	return intFromInterface(val)
}