will branch off into a maps test

This commit is contained in:
2020-06-10 14:52:59 -04:00
parent 161843f4c8
commit c4aa5a1c66
2 changed files with 15 additions and 5 deletions

View File

@@ -21,13 +21,17 @@ func main() {
Ignore: []string{"one", "two", "four", "seven"},
}
mergo.Merge(&dest, src, mergo.WithTransformers())
mergo.Merge(&dest, src, mergo.WithTransformers(StringSliceTransformer{}))
fmt.Println(dest)
// Will print
// {two 2}
}
func MergeStrings(typ reflect.Type) func(dst, src reflect.Value) error {
type StringSliceTransformer struct {
}
// MergeStrings merges two strings
func (s StringSliceTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error {
if typ == reflect.TypeOf([]string{}) {
return func(dst, src reflect.Value) error {