• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

diff/H05-May-2019-

pretty/H05-May-2019-

.travis.ymlH A D05-May-201942

LICENSEH A D05-May-201911.1 KiB

README.mdH A D05-May-20192.1 KiB

go.modH A D05-May-201946

README.md

1Pretty Printing for Go
2======================
3
4[![godebug build status][ciimg]][ci]
5
6Have you ever wanted to get a pretty-printed version of a Go data structure,
7complete with indentation?  I have found this especially useful in unit tests
8and in debugging my code, and thus godebug was born!
9
10[ciimg]: https://travis-ci.org/kylelemons/godebug.svg?branch=master
11[ci]:    https://travis-ci.org/kylelemons/godebug
12
13Quick Examples
14--------------
15
16By default, pretty will write out a very compact representation of a data structure.
17From the [Print example][printex]:
18
19```
20{Name:     "Spaceship Heart of Gold",
21 Crew:     {Arthur Dent:       "Along for the Ride",
22            Ford Prefect:      "A Hoopy Frood",
23            Trillian:          "Human",
24            Zaphod Beeblebrox: "Galactic President"},
25 Androids: 1,
26 Stolen:   true}
27```
28
29It can also produce a much more verbose, one-item-per-line representation suitable for
30[computing diffs][diffex].  See the documentation for more examples and customization.
31
32[printex]: https://godoc.org/github.com/kylelemons/godebug/pretty#example-Print
33[diffex]:  https://godoc.org/github.com/kylelemons/godebug/pretty#example-Compare
34
35Documentation
36-------------
37
38Documentation for this package is available at [godoc.org][doc]:
39
40 * Pretty: [![godoc for godebug/pretty][prettyimg]][prettydoc]
41 * Diff:   [![godoc for godebug/diff][diffimg]][diffdoc]
42
43[doc]:       https://godoc.org/
44[prettyimg]: https://godoc.org/github.com/kylelemons/godebug/pretty?status.png
45[prettydoc]: https://godoc.org/github.com/kylelemons/godebug/pretty
46[diffimg]:   https://godoc.org/github.com/kylelemons/godebug/diff?status.png
47[diffdoc]:   https://godoc.org/github.com/kylelemons/godebug/diff
48
49Installation
50------------
51
52These packages are available via `go get`:
53
54```bash
55$ go get -u github.com/kylelemons/godebug/{pretty,diff}
56```
57
58Other Packages
59--------------
60
61If `godebug/pretty` is not granular enough, I highly recommend
62checking out [cmp][cmp] or [go-spew][spew].
63
64[cmp]: https://godoc.org/github.com/google/go-cmp/cmp
65[spew]: http://godoc.org/github.com/davecgh/go-spew/spew
66