// MustInt always returns value without error,
// it returns 0 if error occurs.
323316
func (c *ConfigFile) MustInt(section, key string, defaultVal ...int) int {
	value, err := c.Int(section, key)
	if len(defaultVal) > 0 && err != nil {
		return defaultVal[0]
	}
	return value
}
241445
func toInt(v reflect.Value) (int64, error) {
	switch v.Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return v.Int(), nil
	case reflect.Interface:
		return toInt(v.Elem())
	}
	return -1, errors.New("unable to convert value to int")
}
1134476
func (ctx *Context) CookieInt(key string, defaults ...int) int {
	return ctx.Cookies().MustInt(key, defaults...)
}
975831
func FindInt(s []int, cb func(s int) bool) (int, bool) {
	for _, i := range s {
		result := cb(i)

		if result {
			return i, true
		}
	}

	return 0, false
}
1191312
func mustParseInt(expr string) (uint, error) {
	num, err := strconv.Atoi(expr)
	if err != nil {
		return 0, fmt.Errorf("Failed to parse int from %s: %s", expr, err)
	}
	if num < 0 {
		return 0, fmt.Errorf("Negative number (%d) not allowed: %s", num, expr)
	}

	return uint(num), nil
}
1366155
func (v *Value) ToInt() (val int64, ok bool) {
	switch v.vType {
	case typeInt:
		val, ok = v.value.(int64)
	default:
	}
	return
}
406234
func must(t *testing.T, err error) {
	if err == nil {
		return
	}
	if t == nil {
		log.Println(err)
	}
	t.Error(err)
}
1177506
func (c *JSONConfigContainer) DefaultInt(key string, defaultval int) int {
	if v, err := c.Int(key); err == nil {
		return v
	}
	return defaultval
}
585449
func (f *Queries) MustInt32(key string, defaults ...int32) int32 {
	if v, ok := f.Values()[key]; ok {
		i, err := strconv.ParseInt(v[0], 10, 32)
		if err == nil {
			return int32(i)
		}
	}
	if len(defaults) > 0 {
		return defaults[0]
	}
	return 0
}
1057214
func MaximumInt(path, in string, data, max int64, exclusive bool) *errors.Validation {
	if (!exclusive && data > max) || (exclusive && data >= max) {
		return errors.ExceedsMaximumInt(path, in, max, exclusive)
	}
	return nil
}
1030951
func (f *Queries) MustUint32(key string, defaults ...uint32) uint32 {
	if v, ok := f.Values()[key]; ok {
		i, err := strconv.ParseUint(v[0], 10, 32)
		if err == nil {
			return uint32(i)
		}
	}
	if len(defaults) > 0 {
		return defaults[0]
	}
	return 0
}
1340428
func (c *ConfigLookup) GetInt(key string) int {
	value, ok := c.Lookup(key)
	if !ok {
		return 0
	}
	return cast.ToInt(value)
}
1307862
func (c *cookies) MustInt(key string, defaults ...int) int {
	ck, err := c.req.Cookie(key)
	if err != nil {
		if len(defaults) > 0 {
			return defaults[0]
		}
		return 0
	}
	v, err := strconv.Atoi(ck.Value)
	if len(defaults) > 0 && err != nil {
		return defaults[0]
	}
	return v
}
1272815
func MustNewValue(v interface{}) *Value {
	ret, err := NewValue(v)
	if err != nil {
		panic(err)
	}
	return ret
}
477448
func (w *ByteWriter) MustWriteInt64(val int64, offset int) int {
	return w.MustWriteVal(val, offset)
}
428792
func (c *secureCookies) MustInt32(key string, defaults ...int32) int32 {
	ck, err := c.req.Cookie(key)
	if err != nil {
		if len(defaults) > 0 {
			return defaults[0]
		}
		return 0
	}
	s := parseSecureCookie(c.secret, ck.Value)
	v, err := strconv.ParseInt(s, 10, 32)
	if len(defaults) > 0 && err != nil {
		return defaults[0]
	}
	return int32(v)
}
633309
func Int(base int, min int, max int) Validator {
	return func(args []string) int {
		if len(args) == 0 {
			return -1
		}
		i, err := strconv.ParseInt(args[0], base, 0)
		if err != nil || int(i) < min || int(i) > max {
			return -1
		}
		return 1
	}
}