go: cloud.google.com/go/internal/pretty Index | Files

package pretty

import "cloud.google.com/go/internal/pretty"

Package pretty implements a simple pretty-printer. It is intended for debugging the output of tests.

It follows pointers and produces multi-line output for complex values like slices, maps and structs.


Package Files

diff.go pretty.go


var Indent = "    "

Indent is the string output at each level of indentation.

func Diff Uses

func Diff(want, got interface{}) (string, bool, error)

Diff compares the pretty-printed representation of two values. The second return value reports whether the two values' representations are identical. If it is false, the first return value contains the diffs.

The output labels the first value "want" and the second "got".

Diff works by invoking the "diff" command. It will only succeed in environments where "diff" is on the shell path.

func Value Uses

func Value(v interface{}) val

Value returns a value that will print prettily when used as an argument for the %v or %s format specifiers. With no flags, struct fields and map keys with default values are omitted. With the '+' or '#' flags, all values are displayed.

This package does not detect cycles. Attempting to print a Value that contains cycles will result in unbounded recursion.

Package pretty imports 10 packages (graph). Updated 2018-06-22. Refresh now. Tools for package owners.