Fix: viper.UnmarshalKey ignores defaults
This seems to be a bug in viper, as soon as we're working with subkeys, things fall apart
This commit is contained in:
parent
467a89c4ba
commit
a6e52d9d3d
@ -34,7 +34,13 @@ func SetConfigDefaults() {
|
||||
}
|
||||
|
||||
func LoadConfig() {
|
||||
viper.UnmarshalKey("Service", &C)
|
||||
// Does not work with partially overrides, only GetXXX does resolve the subkeys correctly
|
||||
// https://github.com/spf13/viper/issues/798
|
||||
// https://github.com/spf13/viper/issues/309
|
||||
// viper.UnmarshalKey("Service", &C)
|
||||
C.DNS.Server = viper.GetString("Service.DNS.Server")
|
||||
C.DNS.DefaultTTL = viper.GetUint32("Service.DNS.DefaultTTL")
|
||||
C.Users.ConfigDir = viper.GetString("Service.Users.ConfigDir")
|
||||
}
|
||||
|
||||
func (obj *config) PrettyPrint() string {
|
||||
|
@ -22,7 +22,11 @@ func SetConfigDefaults() {
|
||||
}
|
||||
|
||||
func LoadConfig() {
|
||||
viper.UnmarshalKey("WebAPI", &C)
|
||||
// Does not work with partially overrides, only GetXXX does resolve the subkeys correctly
|
||||
// https://github.com/spf13/viper/issues/798
|
||||
// https://github.com/spf13/viper/issues/309
|
||||
// viper.UnmarshalKey("WebAPI", &C)
|
||||
C.ListenAddress = viper.GetString("WebAPI.ListenAddress")
|
||||
}
|
||||
|
||||
func (obj *config) PrettyPrint() string {
|
||||
|
Loading…
Reference in New Issue
Block a user