Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
package mergo

import (
"errors"
"fmt"
"reflect"
)

var Skip = errors.New("mergo: skip custom transformer")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error var Skip should have name of the form ErrFoo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported var Skip should have comment or be unexported


func hasMergeableFields(dst reflect.Value) (exported bool) {
for i, n := 0, dst.NumField(); i < n; i++ {
field := dst.Type().Field(i)
Expand Down Expand Up @@ -82,7 +85,10 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
if config.Transformers != nil && !isReflectNil(dst) && dst.IsValid() {
if fn := config.Transformers.Transformer(dst.Type()); fn != nil {
err = fn(dst, src)
return
// Allow users to judge by the type of DST and SRC, and skip the check
if err != Skip {
return
}
}
}

Expand Down