commit | 68d2bbec656a1335b130c746bdbda409c21bd190 | [log] [tgz] |
---|---|---|
author | Kyle Lemons <kevlar@google.com> | Wed Apr 06 21:19:19 2016 |
committer | Kyle Lemons <kevlar@google.com> | Wed Apr 06 21:19:19 2016 |
tree | f9fc368ba780b8c2505b7bc9529cb379f283c240 | |
parent | fffda665884a378c804638f36a4a447a721063c4 [diff] |
Improve diffable output for lists
Have you ever wanted to get a pretty-printed version of a Go data structure, complete with indentation? I have found this especially useful in unit tests and in debugging my code, and thus godebug was born!
By default, pretty will write out a very compact representation of a data structure. From the Print example:
{Name: "Spaceship Heart of Gold", Crew: {Arthur Dent: "Along for the Ride", Ford Prefect: "A Hoopy Frood", Trillian: "Human", Zaphod Beeblebrox: "Galactic President"}, Androids: 1, Stolen: true}
It can also produce a much more verbose, one-item-per-line representation suitable for computing diffs. See the documentation for more examples and customization.
Documentation for this package is available at godoc.org:
These packages are available via go get
:
$ go get -u github.com/kylelemons/godebug/{pretty,diff}
If godebug/pretty
is not granular enough, I highly recommend checking out go-spew.