google / go-cmp

Package for comparing Go values in tests
BSD 3-Clause "New" or "Revised" License
4.08k stars 209 forks source link

How to add more context to Diff output? #358

Open freakytoad1 opened 2 months ago

freakytoad1 commented 2 months ago

I like the default output of the .Diff() function but would love more lines of context around the differences. After looking through different examples, I can't figure out how to do this. Digging into the code of cmp, it looks like the context is hardcoded to 2 https://github.com/google/go-cmp/blob/c3ad8435e7bef96af35732bc0789e5a2278c6d5f/cmp/report_compare.go#L13

Is there a way to override this value?