You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand that it doesn't make sense to go in and try to support all possible core-ish types. E.g. like json.RawMessage as in #62.
Requesting an Equal method for the parent type may not be the best way to solve the culprit, a few caveats:
If that parent type was the one to be compared, there's no need anymore to use deep, one could just use the Equal method
If the type is used in hundreds of different parent types, there's a lot of Equal methods to write (a generator could be used/created)
The type in question as well the parent type(s) may not be in a package you control, so providing an Equal method is actually impossible
What I've seen in different other utilities is to offer a Hook for a type, which could be what is just missing. deep doesn't need to understand the type except to provide the framework for these hooks and this also allows to prototype a compare functions also for foreign types.
I understand that it doesn't make sense to go in and try to support all possible core-ish types. E.g. like
json.RawMessage
as in #62.Requesting an
Equal
method for the parent type may not be the best way to solve the culprit, a few caveats:Equal
methodEqual
method is actually impossibleWhat I've seen in different other utilities is to offer a Hook for a type, which could be what is just missing.
deep
doesn't need to understand the type except to provide the framework for these hooks and this also allows to prototype a compare functions also for foreign types.Examples:
deep already uses the package
reflect
, so there's no additional package needed.Idea very rough from mind and may be incorrect. Good enough to show the idea:
Would be used like:
Missing above: diff return, which would need to be incorporated in the idea as well
Options to explore for
EqualFunc
:type EqualFunc func(a, b interface) (bool, error)
and use actual values instead of reflect.ValueIs such a hook a fitting candidate for deep in your opinion?
The text was updated successfully, but these errors were encountered: