Skip to content

Commit

Permalink
fix: do not allow overwriting the mapstructure output
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark committed Jun 24, 2024
1 parent 7dbe493 commit 5964efa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,17 +949,21 @@ func (v *Viper) decodeStructKeys(input any, opts ...DecoderConfigOption) ([]stri
func defaultDecoderConfig(output any, opts ...DecoderConfigOption) *mapstructure.DecoderConfig {
c := &mapstructure.DecoderConfig{
Metadata: nil,
Result: output,
WeaklyTypedInput: true,
DecodeHook: mapstructure.ComposeDecodeHookFunc(
mapstructure.StringToTimeDurationHookFunc(),
// mapstructure.StringToSliceHookFunc(","),
stringToWeakSliceHookFunc(","),
),
}

for _, opt := range opts {
opt(c)
}

// Do not allow overwriting the output
c.Result = output

return c
}

Expand Down

0 comments on commit 5964efa

Please sign in to comment.