jinzhu / copier

Copier for golang, copy value from struct to struct and more
MIT License
5.58k stars 490 forks source link

Added utility function CopyNonEmpty() that ignores empty fields in a struct while copying #60

Closed rahulkhairwar closed 4 years ago

rahulkhairwar commented 4 years ago

Implementation for 36. Added a function CopyNonEmpty(), which copies only the non-zero fields for different data types.

rahulkhairwar commented 4 years ago

@jinzhu Hi, I would like to request a review for an implementation for the logged issue #36. I have added a new feature function, while keeping backward compatibility. Please do let me know if you think I should change something! Cheers!

dwthien commented 4 years ago

Hi @jinzhu , are we have this method (CopyNonEmpty) before? This is the best method for updating a struct.

frederikhors commented 4 years ago

Please @jinzhu, enlighten us with your wisdom! : smile:

jinzhu commented 4 years ago

Thank you for your PR, Added CopyWithOption method to replace this one.