commit | a85deda102889db7d4e7c33181f6470a49e5e2bb | [log] [tgz] |
---|---|---|
author | Kyle Lemons <kyle@kylelemons.net> | Sun Aug 20 00:15:41 2017 |
committer | Kyle Lemons <kyle@kylelemons.net> | Sun Aug 20 00:15:41 2017 |
tree | f9b9bd04afb4041dc74c7cf2f2093624bc8a3ba9 | |
parent | 62304252c7e450a41f15acb045134d8d23bd96a9 [diff] |
Add support for self-referential structures. See issue #16 and pulls #1 and #17 for context.
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.