mirror of
https://github.com/spf13/viper.git
synced 2024-04-21 12:31:38 +00:00
Add in MustBindEnv.
Adds in a MustBindEnv function which will panic if BindEnv fails.
This commit is contained in:
committed by
Márk Sági-Kazár
parent
3b836e5088
commit
f50ce904a9
@@ -1197,6 +1197,17 @@ func (v *Viper) BindEnv(input ...string) error {
|
||||
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.
|
||||
//
|
||||
// Viper will check to see if an alias exists first.
|
||||
|
||||
Reference in New Issue
Block a user