huandu / go-clone

Clone any Go data structure deeply and thoroughly.
https://pkg.go.dev/github.com/huandu/go-clone
MIT License
305 stars 28 forks source link

Question: no clone #20

Closed matthieuzbo closed 1 year ago

matthieuzbo commented 1 year ago

Hi,

Just a question about your package: If I want a field not to be copied, do I use SetCustomFunc or is there a tag system (like jinzhu copier package copier:"-")?

Thanks

huandu commented 1 year ago

There is no tag system in this package. It's easy to use custom func to ignore a field. Here is a sample: https://go.dev/play/p/mKsbn8YsRWz

As you can see in the sample, in this package, ignoring a field is the same as setting a zero value to the field after cloned.

matthieuzbo commented 1 year ago

Thanks.

huandu commented 1 year ago

I find that struct tags can be much more efficient than custom func, so I add a new feature to support tag system. Check out this new feature in the latest release.