At the moment, it's possible to define a set of types, annotated with mapstructure tags, like so:
type OtherConfig struct {
X string `mapstructure:"x-value"`
}
type Config struct {
Host string `mapstructure:"host"`
Other *OtherConfig `mapstructure:"other"`
}
Then we can just run:
var c *Config
viper.ReadInConfig()
viper.Unmarshal(&c)
And it will just work. But setting the default values will break this clean format... It would be really nice to add default values inside the tags like:
type OtherConfig {
X string `mapstructure:"x-value" viperdefault:"I'm a default string"`
}
I agree with this.
It's why I'm not sure whether to use viper or another configuration library.
Most helpful comment
I agree with this.
It's why I'm not sure whether to use viper or another configuration library.