pretty

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2018 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Overview

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. It also provides convenience wrappers for functions in packages fmt and log.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(format string, a ...interface{}) error

Errorf is a convenience wrapper for fmt.Errorf.

Calling Errorf(f, x, y) is equivalent to fmt.Errorf(f, Formatter(x), Formatter(y)).

func Formatter

func Formatter(x interface{}) (f fmt.Formatter)

Formatter makes a wrapper, f, that will format x as go source with line breaks and tabs. Object f responds to the "%v" formatting verb when both the "#" and " " (space) flags are set, for example:

fmt.Sprintf("%# v", Formatter(x))

If one of these two flags is not set, or any other verb is used, f will format x according to the usual rules of package fmt. In particular, if x satisfies fmt.Formatter, then x.Format will be called.

func Fprintf

func Fprintf(w io.Writer, format string, a ...interface{}) (n int, error error)

Fprintf is a convenience wrapper for fmt.Fprintf.

Calling Fprintf(w, f, x, y) is equivalent to fmt.Fprintf(w, f, Formatter(x), Formatter(y)).

func Log

func Log(a ...interface{})

Log is a convenience wrapper for log.Printf.

Calling Log(x, y) is equivalent to log.Print(Formatter(x), Formatter(y)), but each operand is formatted with "%# v".

func Logf

func Logf(format string, a ...interface{})

Logf is a convenience wrapper for log.Printf.

Calling Logf(f, x, y) is equivalent to log.Printf(f, Formatter(x), Formatter(y)).

func Logln

func Logln(a ...interface{})

Logln is a convenience wrapper for log.Printf.

Calling Logln(x, y) is equivalent to log.Println(Formatter(x), Formatter(y)), but each operand is formatted with "%# v".

func Print

func Print(a ...interface{}) (n int, errno error)

Print pretty-prints its operands and writes to standard output.

Calling Print(x, y) is equivalent to fmt.Print(Formatter(x), Formatter(y)), but each operand is formatted with "%# v".

func Printf

func Printf(format string, a ...interface{}) (n int, errno error)

Printf is a convenience wrapper for fmt.Printf.

Calling Printf(f, x, y) is equivalent to fmt.Printf(f, Formatter(x), Formatter(y)).

func Println

func Println(a ...interface{}) (n int, errno error)

Println pretty-prints its operands and writes to standard output.

Calling Print(x, y) is equivalent to fmt.Println(Formatter(x), Formatter(y)), but each operand is formatted with "%# v".

func Sprint

func Sprint(a ...interface{}) string

Sprint is a convenience wrapper for fmt.Sprintf.

Calling Sprint(x, y) is equivalent to fmt.Sprint(Formatter(x), Formatter(y)), but each operand is formatted with "%# v".

func Sprintf

func Sprintf(format string, a ...interface{}) string

Sprintf is a convenience wrapper for fmt.Sprintf.

Calling Sprintf(f, x, y) is equivalent to fmt.Sprintf(f, Formatter(x), Formatter(y)).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL