commit | 4da1e5af9387fc77d0e824ea7f04a6a39d6df1d3 | [log] [tgz] |
---|---|---|
author | Kyle Lemons <kyle@kylelemons.net> | Sat Apr 02 19:56:31 2016 |
committer | Kyle Lemons <kyle@kylelemons.net> | Sat Apr 02 19:56:31 2016 |
tree | 2735315597937c7bcd55f5ea418afaf2609c4133 | |
parent | 328c2a297d0d7905555ce3bf15d0a7a3d25f7a8c [diff] |
Correctly handle bare nil values
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.