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

Enable custom clone function to call allocator.Clone(old) #12

Closed huandu closed 1 year ago

huandu commented 1 year ago

In a custom clone function, we may need to do a clone on the old value first, then update some fields of cloned value manually. To enable us to work like this, allocator.Clone and allocator.CloneSlowly can temporarily disable custom clone function on the old value to avoid dead loop.

See example ExampleSetCustomFunc_partiallyClone for more details.