config
config copied to clipboard
ParseDeafult does not working with ParseTime
System:
- OS:
Windows 11 - GO Version:
1.24 - Pkg Version:
2.2.6
Describe the bug
If I have value with type time.Duartion and defined default value from tag in my config, I get parsing error on struct binding.
To Reproduce
type TestConfig struct {
WithDefault time.Duration `default:"10s"`
}
func main() {
config.WithOptions(
config.ParseTime,
config.ParseDefault,
)
config.AddDriver(yaml.Driver)
config.LoadFiles("./test.yaml")
cfg := TestConfig{}
if err := config.BindStruct("", &cfg); err != nil {
fmt.Println(err.Error())
}
}
:( Currently, default does not support automatic parsing of time strings.
:( Currently,
defaultdoes not support automatic parsing of time strings.
Any chance you have plans to add such support in near future? :)
@b1p0lar-bear will add support on next version: