-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Thanks for your contribution, and I do have a suggestion which may make this library better.
I'm using this library to write a code generator with generics, and I cannot predict which specific type the user may call.
type DeepCopyGen[T any] interface {
DeepCopyInto(*T)
}
func DeepCopy[T any](in, out *T) {
var _in any = in
if d, ok := _in.(DeepCopyGen[T]); ok {
// use deepcopy-gen
d.DeepCopyInto(out)
return
}
// Have to call pcopy.Preheat each time
pcopy.Copy(in, out, pcopy.WithUsePreheat())
}
if pcopy.Copy
enables preheat by default, then things go easy. Just call pcopy.Copy(in, out)
is enough.
The process could be as follows:
- split
getFromCacheSetAndRun
intoget
andrun
, theget
function returns(*allFieldFunc, bool)
- if
get
returnsnil, false
, callnewAllFieldFunc
andsaveToCache
- call
*allFieldFunc.do
- the
opts ...Option
argument can be removed
What do you think? @guonaihong
Metadata
Metadata
Assignees
Labels
No labels