Allow a configurable env var prefix [#19]

I'd like to keep Prefix's scope fairly limited, because it has potential
to spiral into something magnificently complex. You get one prefix
setting, it goes in `settings` not `environment`, end of feature.
This commit is contained in:
Erin Call
2019-12-23 16:07:49 -08:00
parent db87bd0507
commit 285e9d98a4
2 changed files with 53 additions and 1 deletions

View File

@@ -42,9 +42,17 @@ func (cfg *Config) Populate() error {
return err
}
prefix := cfg.Prefix
if err := envconfig.Process("", cfg); err != nil {
return err
}
if prefix != "" {
if err := envconfig.Process(cfg.Prefix, cfg); err != nil {
return err
}
}
return nil
}