// GetStringDefault same as Get but returns its string representation,
// if key doesn't exist then it returns the "defaultValue".
436283
func (s *Session) GetStringDefault(key string, defaultValue string) string {
	if v := s.GetString(key); v != "" {
		return v
	}

	return defaultValue
}
1024046
func (r *Store) GetInt64Default(key string, def int64) int64 {
	if v, err := r.GetInt64(key); err == nil {
		return v
	}

	return def
}
990905
func GetenvWithDefault(envKey, defValue string) string {
	retVal := os.Getenv(envKey)
	if retVal == "" {
		return defValue
	}
	return retVal
}
59958
func (c Config) GetString(key string) (string, error) {
	var (
		strout string
		val    interface{}
		ok     bool
	)

	if val, ok = c[key]; !ok {
		return strout, ErrConfigNotFound
	}
	if strout, ok = val.(string); !ok {
		return strout, ErrNotAString
	}
	return strout, nil
}
1205245
func (meta Metadata) GetValueString(key string) string {
	return string(meta.GetValue(key))
}
1004698
func (g *Generator) getterDefault(field *descriptor.FieldDescriptorProto, goMessageType string) string {
	if isRepeated(field) {
		return "nil"
	}
	if def := field.GetDefaultValue(); def != "" {
		defaultConstant := g.defaultConstantName(goMessageType, field.GetName())
		if *field.Type != descriptor.FieldDescriptorProto_TYPE_BYTES {
			return defaultConstant
		}
		return "append([]byte(nil), " + defaultConstant + "...)"
	}
	switch *field.Type {
	case descriptor.FieldDescriptorProto_TYPE_BOOL:
		return "false"
	case descriptor.FieldDescriptorProto_TYPE_STRING:
		return `""`
	case descriptor.FieldDescriptorProto_TYPE_GROUP, descriptor.FieldDescriptorProto_TYPE_MESSAGE, descriptor.FieldDescriptorProto_TYPE_BYTES:
		return "nil"
	case descriptor.FieldDescriptorProto_TYPE_ENUM:
		obj := g.ObjectNamed(field.GetTypeName())
		var enum *EnumDescriptor
		if id, ok := obj.(*ImportedDescriptor); ok {
			// The enum type has been publicly imported.
			enum, _ = id.o.(*EnumDescriptor)
		} else {
			enum, _ = obj.(*EnumDescriptor)
		}
		if enum == nil {
			log.Printf("don't know how to generate getter for %s", field.GetName())
			return "nil"
		}
		if len(enum.Value) == 0 {
			return "0 // empty enum"
		}
		first := enum.Value[0].GetName()
		return g.DefaultPackageName(obj) + enum.prefix() + first
	default:
		return "0"
	}
}
998474
func (c *Config) GetString(key string) (s string) {
	s, _ = c.GetStringOk(key)
	return
}
185948
func (c ConfigAttributes) GetString(attrName string, defaultValue string) string {
	if val, ok := c[attrName]; ok {
		return val.(string)
	}
	return defaultValue
}
487613
func (c *Config) ReadDefault(id string, defaultValue string) string {
	val, ok := c.Options[id]
	if !ok {
		return defaultValue
	}
	return val
}
1358552
func GetDefaultsUsageString(ctx Context) string {
	runMode := ctx.GetRunMode()
	defaultBServer := defaultBServer(ctx)
	defaultMDServer := defaultMDServer(ctx)
	return fmt.Sprintf(`  (KEYBASE_RUN_MODE=%s)
  -bserver=%s
  -mdserver=%s`,
		runMode, defaultBServer, defaultMDServer)
}
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
}
897509
func (s Store) GetValue(key string, v ...string) (string, error) {
	kv, err := s.Get(key)
	if err != nil {
		if len(v) > 0 {
			// Take default
			return v[0], nil
		}
		return "", err
	}
	return kv.Value, nil
}
208818
func GetStringByDI(dimensionInfo, key string, defaultValue string) string {
	result, err := factory.GetValueByDI(dimensionInfo, key).ToString()
	if err != nil {
		return defaultValue
	}
	return result
}
805763
func GetString(data []byte, keys ...string) (val string, err error) {
	v, t, _, e := Get(data, keys...)

	if e != nil {
		return "", e
	}

	if t != String {
		return "", fmt.Errorf("Value is not a string: %s", string(v))
	}

	// If no escapes return raw conten
	if bytes.IndexByte(v, '\\') == -1 {
		return string(v), nil
	}

	return ParseString(v)
}
1297660
func (l *LogOptions) GetStringDefault(option, value string) string {
	if v, found := l.ExtendedOptions[option]; found {
		return v.(string)
	}
	return value
}
259759
func (r *Store) GetInt8Default(key string, def int8) int8 {
	if v, err := r.GetInt8(key); err == nil {
		return v
	}

	return def
}
189067
func (r *Reader) StringDefault(name string, def string) string {
	s, err := r.readString(name)
	if err != nil {
		return def
	}
	return s
}