commit | d7035ee8f79a6f295be1963ee76332b3bc9dd620 | [log] [tgz] |
---|---|---|
author | kortschak <kortschak@epistle> | Sat Feb 25 22:09:28 2012 +1030 |
committer | kortschak <kortschak@epistle> | Sat Feb 25 22:09:28 2012 +1030 |
tree | d72023307a2f03702cf4fe913e64ea45f927d40d | |
parent | e201f86731084fdf262954c1325ff4e17f7b5165 [diff] |
Prevent formatter from panic'ing with unexported fields This is not by any means a fix, but a real fix would require cloning much of print.go from fmt.
Package pretty provides pretty-printing for go values. This is useful during debugging, to avoid wrapping long output lines in the terminal.
It provides a function, Formatter, that can be used with any function that accepts a format string. For example,
type LongTypeName struct { longFieldName, otherLongFieldName int } func TestFoo(t *testing.T) { var x []LongTypeName{{1, 2}, {3, 4}, {5, 6}} t.Errorf("%# v", Formatter(x)) }
This package also provides a convenience wrapper for each function in package fmt that takes a format string.
$ goinstall github.com/kr/pretty.go
then
import "github.com/kr/pretty.go"