r3labs / diff

A library for diffing golang structures
Mozilla Public License 2.0
895 stars 84 forks source link

Support cyclic types #104

Open meln5674 opened 1 year ago

meln5674 commented 1 year ago

Presently, calling Diff() on a self-referential value will never return.

This patch records all pointer comparisons, and before each pointer comparison, if a comparison has happened before during the same diff, indicating a cycle was detected, then the comparison does nothing.

This mimics how the standard libraries DeepEqual function works.