MCPcopy
hub / github.com/spf13/viper / BindEnv

Method BindEnv

viper.go:1113–1127  ·  view source on GitHub ↗
(input ...string)

Source from the content-addressed store, hash-verified

1111func BindEnv(input ...string) error { return v.BindEnv(input...) }
1112
1113func (v *Viper) BindEnv(input ...string) error {
1114 if len(input) == 0 {
1115 return fmt.Errorf("missing key to bind to")
1116 }
1117
1118 key := strings.ToLower(input[0])
1119
1120 if len(input) == 1 {
1121 v.env[key] = append(v.env[key], v.mergeWithEnvPrefix(key))
1122 } else {
1123 v.env[key] = append(v.env[key], input[1:]...)
1124 }
1125
1126 return nil
1127}
1128
1129// MustBindEnv wraps BindEnv in a panic.
1130// If there is an error binding an environment variable, MustBindEnv will

Callers 10

MustBindEnvMethod · 0.95
TestEnvFunction · 0.80
TestMultipleEnvFunction · 0.80
TestEmptyEnvFunction · 0.80
TestEmptyEnv_AllowedFunction · 0.80
TestEnvPrefixFunction · 0.80
TestAllKeysWithEnvFunction · 0.80
TestBoundCaseSensitivityFunction · 0.80
TestIsSetFunction · 0.80
BindEnvFunction · 0.80

Calls 1

mergeWithEnvPrefixMethod · 0.95

Tested by 8

TestEnvFunction · 0.64
TestMultipleEnvFunction · 0.64
TestEmptyEnvFunction · 0.64
TestEmptyEnv_AllowedFunction · 0.64
TestEnvPrefixFunction · 0.64
TestAllKeysWithEnvFunction · 0.64
TestBoundCaseSensitivityFunction · 0.64
TestIsSetFunction · 0.64