8dc52a56ea
This hook replaces lib.TranslateKeys and has a number of advantages: 1. Primarily, aliases for fields are defined on the field itself, making the aliases much easier to maintain, and more obvious to the reader. 2. TranslateKeys translation rules are not aware of structure. It could very easily incorrectly translate a key on one struct that was intended to be a translation rule for a completely different struct, leading to very hard to debug errors. The hook removes the need for the unexpected "translation rule is an empty string to indicate stop traversal" special case. 3. TranslateKeys attempts to duplicate a bunch of tree traversal logic that already exists in mapstructure. Using mapstructure for traversal removes the need to traverse the entire structure multiple times, and makes the behaviour more obvious to the reader. This change is being made to enable a future change of replacing PatchSliceOfMaps. TranslateKeys sits in between PatchSliceOfMaps and mapstructure.Decode, so it must be converted to a hook first, before PatchSliceOfMaps can be replaced by a decode hook. |
||
---|---|---|
.. | ||
decode | ||
file | ||
semaphore | ||
cluster.go | ||
cluster_test.go | ||
eof.go | ||
json.go | ||
map_walker.go | ||
map_walker_test.go | ||
math.go | ||
math_test.go | ||
patch_hcl.go | ||
patch_hcl_test.go | ||
path.go | ||
rand.go | ||
retry.go | ||
retry_test.go | ||
rtt.go | ||
rtt_test.go | ||
serf.go | ||
slice.go | ||
slice_test.go | ||
stop_context.go | ||
string.go | ||
string_test.go | ||
telemetry.go | ||
telemetry_test.go | ||
testing_httpserver.go | ||
translate.go | ||
translate_test.go | ||
useragent.go | ||
useragent_test.go | ||
uuid.go |