mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
Add string slice support to defaultDecoderConfig
This way it correctly decodes string slices as well.
This commit is contained in:
parent
25b30aa063
commit
266e588e9e
1 changed files with 5 additions and 2 deletions
7
viper.go
7
viper.go
|
@ -747,13 +747,16 @@ func (v *Viper) Unmarshal(rawVal interface{}) error {
|
|||
}
|
||||
|
||||
// defaultDecoderConfig returns default mapsstructure.DecoderConfig with suppot
|
||||
// of time.Duration values
|
||||
// of time.Duration values & string slices
|
||||
func defaultDecoderConfig(output interface{}) *mapstructure.DecoderConfig {
|
||||
return &mapstructure.DecoderConfig{
|
||||
Metadata: nil,
|
||||
Result: output,
|
||||
WeaklyTypedInput: true,
|
||||
DecodeHook: mapstructure.StringToTimeDurationHookFunc(),
|
||||
DecodeHook: mapstructure.ComposeDecodeHookFunc(
|
||||
mapstructure.StringToTimeDurationHookFunc(),
|
||||
mapstructure.StringToSliceHookFunc(","),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue