mirror of
https://github.com/spf13/viper
synced 2024-12-23 12:07:02 +00:00
Add time.Time (RFC 3339) support to defaultDecoderConfig
This commit is contained in:
parent
aafc9e6bc7
commit
10f9aca639
1 changed files with 3 additions and 2 deletions
5
viper.go
5
viper.go
|
@ -767,8 +767,8 @@ func (v *Viper) Unmarshal(rawVal interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultDecoderConfig returns default mapsstructure.DecoderConfig with suppot
|
// defaultDecoderConfig returns default mapsstructure.DecoderConfig with support
|
||||||
// of time.Duration values & string slices
|
// of time.Duration and time.Time (RFC 3339) values and string slices
|
||||||
func defaultDecoderConfig(output interface{}) *mapstructure.DecoderConfig {
|
func defaultDecoderConfig(output interface{}) *mapstructure.DecoderConfig {
|
||||||
return &mapstructure.DecoderConfig{
|
return &mapstructure.DecoderConfig{
|
||||||
Metadata: nil,
|
Metadata: nil,
|
||||||
|
@ -776,6 +776,7 @@ func defaultDecoderConfig(output interface{}) *mapstructure.DecoderConfig {
|
||||||
WeaklyTypedInput: true,
|
WeaklyTypedInput: true,
|
||||||
DecodeHook: mapstructure.ComposeDecodeHookFunc(
|
DecodeHook: mapstructure.ComposeDecodeHookFunc(
|
||||||
mapstructure.StringToTimeDurationHookFunc(),
|
mapstructure.StringToTimeDurationHookFunc(),
|
||||||
|
mapstructure.StringToTimeHookFunc(time.RFC3339),
|
||||||
mapstructure.StringToSliceHookFunc(","),
|
mapstructure.StringToSliceHookFunc(","),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue