-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Hi all,
Having this code:
type RpcConfig struct {
ServerAddr string `mapstructure:"ADDR"`
}
func main() {
v := viper.New()
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
v.AutomaticEnv()
//v.BindEnv("ADDR")
c := &RpcConfig{}
if err := v.Unmarshal(c); err != nil {
panic(err)
}
log.Printf("conf=%+v", c)
}
and running in this way:
ADDR="test" go run main.go
I got config with empty ServerAddr
. If I remove comment from binding line it works but why viper couldn't get it from mapstructure
tag itself?
Please let me know if I doing something wrong.
razitz, ereyes01, hypnoglow, treystout and msiemens
Metadata
Metadata
Assignees
Labels
No labels