Skip to content

Commit

Permalink
tweak code block for copying to a nil empty interface value
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Pittkin committed Sep 3, 2024
1 parent a767cc8 commit 46abde5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
}

// If possible, simply copy the struct
if from.Type().AssignableTo(to.Type()) {
//if from.Type().AssignableTo(to.Type()) && to.Kind() == reflect.Interface {
if from.Kind() == reflect.Struct && from.Type().AssignableTo(to.Type()) && reflect.TypeOf(to.Interface()) == nil {
to.Set(from)
return
}
Expand Down

0 comments on commit 46abde5

Please sign in to comment.