@@ -52,33 +52,29 @@ func WithForceUnmarshaler() UnmarshalOption {
5252// Decodes time.Duration from strings. Allows custom unmarshaling for structs implementing
5353// encoding.TextUnmarshaler. Allows custom unmarshaling for structs implementing confmap.Unmarshaler.
5454func Decode (input , result any , settings UnmarshalOptions , skipTopLevelUnmarshaler bool ) error {
55- hooks := []mapstructure.DecodeHookFunc {
56- useExpandValue (),
57- expandNilStructPointersHookFunc (),
58- mapstructure .StringToSliceHookFunc ("," ),
59- mapKeyStringToMapKeyTextUnmarshalerHookFunc (),
60- mapstructure .StringToTimeDurationHookFunc (),
61- mapstructure .TextUnmarshallerHookFunc (),
62- // This must come before unmarshalerHookFunc; the two may both want to trigger
63- // their corresponding interface for structs implementing both, and the scalar
64- // interfaces are the ones that will sometimes defer to the non-scalar interfaces.
65- scalarUnmarshalerHookFunc (),
66- unmarshalerHookFunc (result , skipTopLevelUnmarshaler && ! settings .ForceUnmarshaler ),
67- // after the main unmarshaler hook is called,
68- // we unmarshal the embedded structs if present to merge with the result:
69- unmarshalerEmbeddedStructsHookFunc (settings ),
70- zeroSliceAndMapHookFunc (),
71- }
7255 dc := & mapstructure.DecoderConfig {
7356 ErrorUnused : ! settings .IgnoreUnused ,
7457 Result : result ,
7558 TagName : MapstructureTag ,
7659 WeaklyTypedInput : false ,
7760 MatchName : caseSensitiveMatchName ,
7861 DecodeNil : true ,
79- DecodeHook : composehook .ComposeDecodeHookFunc (hooks ... ),
62+ DecodeHook : composehook .ComposeDecodeHookFunc (useExpandValue (),
63+ expandNilStructPointersHookFunc (),
64+ mapstructure .StringToSliceHookFunc ("," ),
65+ mapKeyStringToMapKeyTextUnmarshalerHookFunc (),
66+ mapstructure .StringToTimeDurationHookFunc (),
67+ mapstructure .TextUnmarshallerHookFunc (),
68+ // This must come before unmarshalerHookFunc; the two may both want to trigger
69+ // their corresponding interface for structs implementing both, and the scalar
70+ // interfaces are the ones that will sometimes defer to the non-scalar interfaces.
71+ scalarUnmarshalerHookFunc (),
72+ unmarshalerHookFunc (result , skipTopLevelUnmarshaler && ! settings .ForceUnmarshaler ),
73+ // after the main unmarshaler hook is called,
74+ // we unmarshal the embedded structs if present to merge with the result:
75+ unmarshalerEmbeddedStructsHookFunc (settings ),
76+ zeroSliceAndMapHookFunc ()),
8077 }
81-
8278 decoder , err := mapstructure .NewDecoder (dc )
8379 if err != nil {
8480 return err
0 commit comments