Documentation
¶
Overview ¶
Package pretty pretty-prints Go structures.
This package uses reflection to examine a Go value and can print out in a nice, aligned fashion. It supports three modes (normal, compact, and extended) for advanced use.
See the Reflect and Print examples for what the output looks like.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // CompareConfig is the default configuration used for Compare. CompareConfig = &Config{ Diffable: true, IncludeUnexported: true, } // DefaultConfig is the default configuration used for all other top-level functions. DefaultConfig = &Config{} )
Default Config objects
Functions ¶
func Compare ¶
func Compare(got, want interface{}) string
Compare returns a string containing a line-by-line unified diff of the values in got and want, using the CompareConfig.
Each line in the output is prefixed with '+', '-', or ' ' to indicate if it should be added to, removed from, or is correct for the "got" value with respect to the "want" value.
func Fprint ¶
Fprint writes the representation of the given value to the writer according to the DefaultConfig.
Types ¶
type Config ¶
type Config struct { // Verbosity options Compact bool // One-line output. Overrides Diffable. Diffable bool // Adds extra newlines for more easily diffable output. // Field and value options IncludeUnexported bool // Include unexported fields in output PrintStringers bool // Call String on a fmt.Stringer SkipZeroFields bool // Skip struct fields that have a zero value. // Output transforms ShortList int // Maximum character length for short lists if nonzero. }
A Config represents optional configuration parameters for formatting.
Some options, notably ShortList, dramatically increase the overhead of pretty-printing a value.
func (*Config) Compare ¶
Compare returns a string containing a line-by-line unified diff of the values in got and want according to the cfg.
func (*Config) Fprint ¶
Fprint writes the representation of the given value to the writer according to the cfg.