We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It seems neither mergo nor mapstructure currently provide this ability. Made a small addition to allow arbitrarily matching map keys:
mergo
mapstructure
func merge(dst, src map[string]any, depth int) map[string]any { if depth > mergeMaxDepth { panic("too deep!") } for key, srcVal := range src { for k := range dst { if matchKey(k, key) { // overwrite key key = k srcMap, srcMapOk := mapify(srcVal) dstMap, dstMapOk := mapify(dst[k]) if srcMapOk && dstMapOk { srcVal = merge(dstMap, srcMap, depth+1) } break } } dst[key] = srcVal } return dst }
Default
var matchKey = func(a, b string) bool { return strings.Compare(a, b) == 0 }
but also
var matchKey = strings.EqualFold
The text was updated successfully, but these errors were encountered:
No branches or pull requests
It seems neither
mergo
normapstructure
currently provide this ability. Made a small addition to allow arbitrarily matching map keys:Default
but also
The text was updated successfully, but these errors were encountered: