Repository navigation
is it possible to watch tracked env vars? #1947
Replies: 1 comment
|
Viper doesn't have an environment-variable change callback. It does reread the current process's environment on each getter call, though. Checked with Viper 1.21.0: v := viper.New()
if err := v.BindEnv("mode", "APP_MODE"); err != nil {
panic(err)
}
if err := os.Setenv("APP_MODE", "before"); err != nil {
panic(err)
}
fmt.Println(v.GetString("mode")) // before
if err := os.Setenv("APP_MODE", "after"); err != nil {
panic(err)
}
fmt.Println(v.GetString("mode")) // afterChanging an If the goal is live configuration from outside the process, a config file plus Reference: working with environment variables. |
Uh oh!
There was an error while loading. Please reload this page.
Hi. greatly appreciated the awesome work done here.
I am wondering whether is possible to watch for changes over environment variables?
Regards,
Julio
All reactions