Skip to content

Commit

Permalink
assign an empty type when patch value is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
purehyperbole committed Jul 12, 2021
1 parent 04a5761 commit 5054057
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion change_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ func (c *ChangeValue) Set(value reflect.Value, convertCompatibleTypes bool) {
}
c.target.Set(value.Convert(c.target.Type()))
} else {
c.target.Set(value)
if value.IsValid() {
c.target.Set(value)
} else {
t := c.target.Elem()
t.Set(reflect.Zero(t.Type()))
}
}
c.SetFlag(FlagApplied)
}
Expand Down

0 comments on commit 5054057

Please sign in to comment.