Skip to content

Commit

Permalink
fix jinzhu#182 copy of slice doesn't replace the whole slice
Browse files Browse the repository at this point in the history
  • Loading branch information
jheroy committed May 17, 2023
1 parent 83982c7 commit c48356f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
}
}
}

if to.Len() > from.Len() {
to.SetLen(from.Len())
}

if to.Cap() > from.Cap() {
to.SetCap(from.Cap())
}

return
}
}
Expand Down

0 comments on commit c48356f

Please sign in to comment.