From 251d52b1614527b43b2d47dbf01efdff059aa04e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 14 Sep 2021 10:12:13 -0700 Subject: [PATCH] improve comments for matchname --- mapstructure.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mapstructure.go b/mapstructure.go index fd722be..783923d 100644 --- a/mapstructure.go +++ b/mapstructure.go @@ -260,7 +260,8 @@ type DecoderConfig struct { TagName string // MatchName is the function used to match the map key to the struct - // field name or tag. Defaults to `strings.EqualFold`. + // field name or tag. Defaults to `strings.EqualFold`. This can be used + // to implement case-sensitive tag values, support snake casing, etc. MatchName func(mapKey, fieldName string) bool } @@ -1436,6 +1437,7 @@ func (d *Decoder) matchName(mapKey, fieldName string) bool { if d.config.MatchName != nil { return d.config.MatchName(mapKey, fieldName) } + return strings.EqualFold(mapKey, fieldName) }