Skip to content

Commit

Permalink
patched differ
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed May 17, 2023
1 parent 20fe012 commit fa1777d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 0 additions & 1 deletion differ.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (d *Differ) diff(changeLog *ChangeLog, aPath *Path, from, to interface{}, f
if to != nil {
to = d.decoder(to)
}

}

if d.structDiffer != nil {
Expand Down
18 changes: 14 additions & 4 deletions struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,23 @@ func (s *structDiffer) diff(changeLog *ChangeLog, path *Path, from, to interface
if fromValue == nil && toValue == nil {
continue
}

if field.differ != nil {
diffChangeType := ChangeTypeUpdate
if field.Kind == reflect.Slice {
fromValue = field.from.Addr(fromPtr)
toValue = field.to.Addr(toPtr)
if fromValue != nil {
fromValue = field.from.Addr(fromPtr)
} else {
diffChangeType = ChangeTypeCreate
}
if toValue != nil {
toValue = field.to.Addr(toPtr)
diffChangeType = ChangeTypeDelete
}
}
if fromValue == nil {

}
if err = field.differ.diff(changeLog, path.Field(field.name), fromValue, toValue, ChangeTypeUpdate); err != nil {
if err = field.differ.diff(changeLog, path.Field(field.name), fromValue, toValue, diffChangeType); err != nil {
return err
}
continue
Expand Down

0 comments on commit fa1777d

Please sign in to comment.