File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 173173// Public: "I made it through!"
174174// }
175175//
176+ // # Custom Decoding with Unmarshaler
177+ //
178+ // Types can implement the Unmarshaler interface to control their own decoding. The interface
179+ // behaves similarly to how UnmarshalJSON does in the standard library. It can be used as an
180+ // alternative or companion to a DecodeHook.
181+ //
182+ // type TrimmedString string
183+ //
184+ // func (t *TrimmedString) UnmarshalMapstructure(input any) error {
185+ // str, ok := input.(string)
186+ // if !ok {
187+ // return fmt.Errorf("expected string, got %T", input)
188+ // }
189+ // *t = TrimmedString(strings.TrimSpace(str))
190+ // return nil
191+ // }
192+ //
193+ // See the Unmarshaler interface documentation for more details.
194+ //
176195// # Other Configuration
177196//
178197// mapstructure is highly configurable. See the DecoderConfig struct
You can’t perform that action at this time.
0 commit comments