davecgh / go-spew

Implements a deep pretty printer for Go data structures to aid in debugging
ISC License
5.98k stars 361 forks source link

Add config options AlwaysIncludeTrailingComma, DisableNilValues #60

Open atombender opened 7 years ago

atombender commented 7 years ago

Adds config option AlwaysIncludeTrailingComma, which forces the writing of commas in arrays/slices/maps. Useful in tests to avoid false positives when diffing. This is a prerequisite to resolving this Testify issue.

Building on that commit is a new config option DisableNilValues. Background: We have a bunch of tests that use Spew to generate "golden" test data. This is great, but often one adds a new, optional field to a struct that's part of this data, and suddenly all the test data is broken because the new filed is nil everywhere. It's onerous to update all test data for such zero-value fields. This fixes that.

atombender commented 7 years ago

Oh, and this fixes #54.

atombender commented 7 years ago

@davecgh Thoughts? I was thinking of changing the nil functionality to disable all zero values, which will cover more use cases.

kmudrick commented 6 years ago

I really like the DisableNilValues option

georgelesica-wf commented 5 years ago

@davecgh do you think we could move this along? It would help us resolve https://github.com/stretchr/testify/issues/288. Or, if it's not going to happen, we can just close that or maybe try to fix it on our end. Either way works for me.

maxatome commented 5 years ago

For the DisableNilValues I think #77 is better suited as it covers all zero cases.