Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 9ed2c4b

Browse files
committed
Update godoc about DecodeHooks
1 parent 95075d6 commit 9ed2c4b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

mapstructure.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ import (
161161
// data transformations. See "DecodeHook" in the DecoderConfig
162162
// struct.
163163
//
164-
// The type should be DecodeHookFuncType or DecodeHookFuncKind.
165-
// Either is accepted. Types are a superset of Kinds (Types can return
166-
// Kinds) and are generally a richer thing to use, but Kinds are simpler
167-
// if you only need those.
164+
// The type must be one of DecodeHookFuncType, DecodeHookFuncKind, or
165+
// DecodeHookFuncValue.
166+
// Values are a superset of Types (Values can return types), and Types are a
167+
// superset of Kinds (Types can return Kinds) and are generally a richer thing
168+
// to use, but Kinds are simpler if you only need those.
168169
//
169170
// The reason DecodeHookFunc is multi-typed is for backwards compatibility:
170171
// we started with Kinds and then realized Types were the better solution,
@@ -189,10 +190,13 @@ type DecodeHookFuncValue func(from reflect.Value, to reflect.Value) (interface{}
189190
type DecoderConfig struct {
190191
// DecodeHook, if set, will be called before any decoding and any
191192
// type conversion (if WeaklyTypedInput is on). This lets you modify
192-
// the values before they're set down onto the resulting struct.
193+
// the values before they're set down onto the resulting struct. The
194+
// DecodeHook is called for every map and value in the input. This means
195+
// that if a struct has embedded fields with squash tags the decode hook
196+
// is called only once with all of the input data, not once for each
197+
// embedded struct.
193198
//
194-
// If an error is returned, the entire decode will fail with that
195-
// error.
199+
// If an error is returned, the entire decode will fail with that error.
196200
DecodeHook DecodeHookFunc
197201

198202
// If ErrorUnused is true, then it is an error for there to exist

0 commit comments

Comments
 (0)