kr / pretty

Pretty printing for Go values
http://godoc.org/github.com/kr/pretty
MIT License
1.36k stars 155 forks source link

Fix infinite recursion when diffing structs with cycles #58

Closed stolowski closed 4 years ago

stolowski commented 5 years ago

Unlike Format, the Diff method doesn't detect cycles and goes into infinite recursion on struct with cycles. This PR attempts to fix it with an approach similiar to that of formatter, although - I think - in case of diff it's enough to detect cycle on just one side of the diff comparision, as the recursion will stop on the cycle on left side, or on actual difference. The test case contains simple reproducers.

mvo5 commented 5 years ago

I just hit the same issue, anything I can do to help (test, review, anything...) to move this PR forward? Thanks :)

mvo5 commented 4 years ago

I think https://github.com/kr/pretty/pull/64 fixed this now so this can probably be closed now (unless I miss something).