commit | 7c2843eff2f0592946de18d0d01134b08b414bec | [log] [tgz] |
---|---|---|
author | Kyle Lemons <kyle@kylelemons.net> | Sun May 05 01:14:00 2019 |
committer | Kyle Lemons <kyle@kylelemons.net> | Sun May 05 01:14:00 2019 |
tree | 68001087acc072b0adec3a277b192ad82dc62ea8 | |
parent | 8db7c349f9dc323408a97a8d3b8873aab177c271 [diff] |
pretty: Note that Compare doesn't compare types.
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.