forked from mirror/viper
Add in MustBindEnv.
Adds in a MustBindEnv function which will panic if BindEnv fails.
This commit is contained in:
parent
3b836e5088
commit
f50ce904a9
11
viper.go
11
viper.go
|
@ -1197,6 +1197,17 @@ func (v *Viper) BindEnv(input ...string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MustBindEnv wraps BindEnv in a panic.
|
||||||
|
// If there is an error binding an environment variable, MustBindEnv will
|
||||||
|
// panic.
|
||||||
|
func MustBindEnv(input ...string) { v.MustBindEnv(input...) }
|
||||||
|
|
||||||
|
func (v *Viper) MustBindEnv(input ...string) {
|
||||||
|
if err := v.BindEnv(input...); err != nil {
|
||||||
|
panic(fmt.Sprintf("error while binding environment variable: %v", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Given a key, find the value.
|
// Given a key, find the value.
|
||||||
//
|
//
|
||||||
// Viper will check to see if an alias exists first.
|
// Viper will check to see if an alias exists first.
|
||||||
|
|
Loading…
Reference in New Issue