commit | ce74423a4a2776bf9c580a4a6902cc6de6e39248 | [log] [tgz] |
---|---|---|
author | Kyle Lemons <kyle@kylelemons.net> | Tue Apr 30 01:51:39 2019 |
committer | Kyle Lemons <kyle@kylelemons.net> | Tue Apr 30 01:51:39 2019 |
tree | 15d8435e460e50a79025ac585234977a0605fa7a | |
parent | 7a67e28dea99791f60d42a5fe5b0e92b0db94ab8 [diff] | |
parent | 009bb93e63da0d3607040fbc75007ff3e635a5a5 [diff] |
Merge branch 'master' into selfref
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.