dynamic: invert if

Signed-off-by: c9s <yoanlin93@gmail.com>
This commit is contained in:
c9s 2022-06-30 15:48:06 +08:00
parent b15e8d0ce4
commit 903d773025
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -24,7 +24,11 @@ func MergeStructValues(dst, src interface{}) {
}
// if there is a field with the same name
if fieldSrcType, ok := srcStructType.FieldByName(fieldName); ok {
fieldSrcType, found := srcStructType.FieldByName(fieldName)
if !found {
continue
}
// ensure that the type is the same
if fieldSrcType.Type == fieldType.Type {
srcValue := reflect.ValueOf(src).Elem().FieldByName(fieldName)
@ -34,5 +38,4 @@ func MergeStructValues(dst, src interface{}) {
}
}
}
}
}