// IntWithDefault ...
335636
func IntWithDefault(val *int, defaultValue int) int {
	if val == nil {
		return defaultValue
	}
	return *val
}
834160
func (cb *ConfigBackend) GetWithDefault(key string, defaultValue string) (string, error) {
	sort, recursive := true, false
	resp, err := cb.etcdlib.Get(key, sort, recursive)
	if err != nil {
		etcdErr, ok := err.(*etcdlib.EtcdError)
		if ok && etcdErr.ErrorCode == 100 {
			return defaultValue, nil
		}
		return "", err
	}
	return resp.Node.Value, nil
}
616259
func WithDefaultAttributes(attrs ...trace.Attribute) Option {
	return func(t *Transport) {
		t.defaultAttributes = attrs
	}
}
1300839
func AskForIntFromReaderWithDefault(messageToPrint string, defaultValue int, inputReader io.Reader) (int64, error) {
	userInputStr, err := AskForStringFromReaderWithDefault(messageToPrint, fmt.Sprintf("%d", defaultValue), inputReader)
	if err != nil {
		return 0, err
	}
	return strconv.ParseInt(userInputStr, 10, 64)
}
1177593
func (c *JSONConfigContainer) DefaultInt64(key string, defaultval int64) int64 {
	if v, err := c.Int64(key); err == nil {
		return v
	}
	return defaultval
}
273861
func (fv FlagValues) Int(name string, defaultValue int) (int, error) {
	value, found := fv[name]
	if !found {
		return defaultValue, nil
	}
	i, err := strconv.Atoi(value)
	if err != nil {
		return 0, fmt.Errorf("flag %q: cannot parse integer from %q", name, value)
	}
	return i, nil
}
1294216
func (s Session) GetDefault(key string, value interface{}, defaultValue interface{}) interface{} {
	v, e := s.GetInto(key, value, false)
	if e != nil {
		v = defaultValue
	}
	return v
}
607326
func (f *PrintFlags) WithDefaultOutput(output string) *PrintFlags {
	f.OutputFormat = &output
	return f
}
1127569
func (m *Module) ConnectDefault() (*sql.DB, error) {
	ds, err := m.GetBackend(m.env.String())
	if err != nil {
		return nil, err
	}
	return ds.Connect()
}
1093171
func (v *Variable) inferTypeFromDefault() VariableType {
	if v.Default == nil {
		return VariableTypeString
	}

	var s string
	if err := hilmapstructure.WeakDecode(v.Default, &s); err == nil {
		v.Default = s
		return VariableTypeString
	}

	var m map[string]interface{}
	if err := hilmapstructure.WeakDecode(v.Default, &m); err == nil {
		v.Default = m
		return VariableTypeMap
	}

	var l []interface{}
	if err := hilmapstructure.WeakDecode(v.Default, &l); err == nil {
		v.Default = l
		return VariableTypeList
	}

	return VariableTypeUnknown
}
698439
func (r *Reader) Int64Default(name string, def int64) int64 {
	i, err := r.readInt64(name)
	if err != nil {
		return def
	}
	return i
}
832757
func GetIntOrDefault(key string, defVal int) int {
	viperLock.RLock()
	defer viperLock.RUnlock()

	if val := viper.GetInt(key); val != 0 {
		return val
	}

	return defVal
}
1013452
func (e Entry) IntDefault(def int) (int, error) {
	v := e.ValueRaw
	if v == nil {
		return def, errFindParse.Format("int", e.Key)
	}

	switch vv := v.(type) {
	case string:
		val, err := strconv.Atoi(vv)
		if err != nil {
			return def, err
		}
		return val, nil
	case int:
		return vv, nil
	case int8:
		return int(vv), nil
	case int16:
		return int(vv), nil
	case int32:
		return int(vv), nil
	case int64:
		return int(vv), nil
	case uint:
		return int(vv), nil
	case uint8:
		return int(vv), nil
	case uint16:
		return int(vv), nil
	case uint32:
		return int(vv), nil
	case uint64:
		return int(vv), nil
	}

	return def, errFindParse.Format("int", e.Key)
}
1237139
func TimeWithDefault(val *time.Time, defaultValue time.Time) time.Time {
	if val == nil {
		return defaultValue
	}
	return *val
}
117879
func (r *Reader) IntDefault(name string, def int) int {
	i, err := r.readInt(name)
	if err != nil {
		return def
	}
	return i
}
851369
func (s *Rule) SetIsDefault(v bool) *Rule {
	s.IsDefault = &v
	return s
}
676015
func (e Entry) Int64Default(def int64) (int64, error) {
	v := e.ValueRaw
	if v == nil {
		return def, fmt.Errorf(errFindParse, "int64", e.Key)
	}

	if vint64, ok := v.(int64); ok {
		return vint64, nil
	}

	if vint, ok := v.(int); ok {
		return int64(vint), nil
	}

	if vstring, sok := v.(string); sok {
		return strconv.ParseInt(vstring, 10, 64)
	}

	return def, fmt.Errorf(errFindParse, "int64", e.Key)
}