pp: github.com/k0kubun/pp Index | Files

package pp

import "github.com/k0kubun/pp"

Index

Package Files

color.go pp.go printer.go sort.go

Constants

const (
    Black uint16
    Red
    Green
    Yellow
    Blue
    Magenta
    Cyan
    White
)
const (
    BackgroundBlack uint16
    BackgroundRed
    BackgroundGreen
    BackgroundYellow
    BackgroundBlue
    BackgroundMagenta
    BackgroundCyan
    BackgroundWhite
)
const (
    // Bold flag for ColorScheme.
    Bold uint16 = 1<<bitsBold | NoColor
)
const (
    // No color
    NoColor uint16 = 1 << 15
)

Variables

var (
    // If the length of array or slice is larger than this,
    // the buffer will be shorten as {...}.
    BufferFoldThreshold = 1024
    // PrintMapTypes when set to true will have map types will always appended to maps.
    PrintMapTypes = true
)
var (
    // DEPRECATED: Use PrettyPrinter.SetColoringEnabled().
    ColoringEnabled = true
)
var WithLineInfo bool

WithLineInfo add file name and line information to output call this function with care, because getting stack has performance penalty

func Errorf Uses

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

Errorf formats given arguments and returns it as error type.

func Fatal Uses

func Fatal(a ...interface{})

Fatal prints given arguments and finishes execution with exit status 1.

func Fatalf Uses

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

Fatalf prints a given format and finishes execution with exit status 1.

func Fatalln Uses

func Fatalln(a ...interface{})

Fatalln prints given arguments with newline and finishes execution with exit status 1.

func Fprint Uses

func Fprint(w io.Writer, a ...interface{}) (n int, err error)

Fprint prints given arguments to a given writer.

func Fprintf Uses

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

Fprintf prints format to a given writer.

func Fprintln Uses

func Fprintln(w io.Writer, a ...interface{}) (n int, err error)

Fprintln prints given arguments to a given writer with newline.

func GetDefaultOutput Uses

func GetDefaultOutput() io.Writer

GetOutput returns pp's default output.

func Print Uses

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

Print prints given arguments.

func Printf Uses

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

Printf prints a given format.

func Println Uses

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

Println prints given arguments with newline.

func ResetColorScheme Uses

func ResetColorScheme()

ResetColorScheme resets colorscheme to default.

func ResetDefaultOutput Uses

func ResetDefaultOutput()

Change Print* functions' output to default one.

func SetColorScheme Uses

func SetColorScheme(scheme ColorScheme)

SetColorScheme takes a colorscheme used by all future Print calls.

func SetDefaultMaxDepth Uses

func SetDefaultMaxDepth(v int)

SetMaxDepth sets the printer's Depth, -1 prints all

func SetDefaultOutput Uses

func SetDefaultOutput(o io.Writer)

Change Print* functions' output to a given writer. For example, you can limit output by ENV.

func init() {
	if os.Getenv("DEBUG") == "" {
		pp.SetDefaultOutput(ioutil.Discard)
	}
}

func Sprint Uses

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

Sprint formats given arguemnts and returns the result as string.

func Sprintf Uses

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

Sprintf formats with pretty print and returns the result as string.

func Sprintln Uses

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

Sprintln formats given arguemnts with newline and returns the result as string.

type ColorScheme Uses

type ColorScheme struct {
    Bool            uint16
    Integer         uint16
    Float           uint16
    String          uint16
    StringQuotation uint16
    EscapedChar     uint16
    FieldName       uint16
    PointerAdress   uint16
    Nil             uint16
    Time            uint16
    StructName      uint16
    ObjectLength    uint16
}

To use with SetColorScheme.

type PrettyPrinter Uses

type PrettyPrinter struct {

    // WithLineInfo add file name and line information to output
    // call this function with care, because getting stack has performance penalty
    WithLineInfo bool
    // contains filtered or unexported fields
}

func New Uses

func New() *PrettyPrinter

New creates a new PrettyPrinter that can be used to pretty print values

func (*PrettyPrinter) Errorf Uses

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

Errorf formats given arguments and returns it as error type.

func (*PrettyPrinter) Fatal Uses

func (pp *PrettyPrinter) Fatal(a ...interface{})

Fatal prints given arguments and finishes execution with exit status 1.

func (*PrettyPrinter) Fatalf Uses

func (pp *PrettyPrinter) Fatalf(format string, a ...interface{})

Fatalf prints a given format and finishes execution with exit status 1.

func (*PrettyPrinter) Fatalln Uses

func (pp *PrettyPrinter) Fatalln(a ...interface{})

Fatalln prints given arguments with newline and finishes execution with exit status 1.

func (*PrettyPrinter) Fprint Uses

func (pp *PrettyPrinter) Fprint(w io.Writer, a ...interface{}) (n int, err error)

Fprint prints given arguments to a given writer.

func (*PrettyPrinter) Fprintf Uses

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

Fprintf prints format to a given writer.

func (*PrettyPrinter) Fprintln Uses

func (pp *PrettyPrinter) Fprintln(w io.Writer, a ...interface{}) (n int, err error)

Fprintln prints given arguments to a given writer with newline.

func (*PrettyPrinter) GetOutput Uses

func (pp *PrettyPrinter) GetOutput() io.Writer

GetOutput returns pp's output.

func (*PrettyPrinter) Print Uses

func (pp *PrettyPrinter) Print(a ...interface{}) (n int, err error)

Print prints given arguments.

func (*PrettyPrinter) Printf Uses

func (pp *PrettyPrinter) Printf(format string, a ...interface{}) (n int, err error)

Printf prints a given format.

func (*PrettyPrinter) Println Uses

func (pp *PrettyPrinter) Println(a ...interface{}) (n int, err error)

Println prints given arguments with newline.

func (*PrettyPrinter) ResetColorScheme Uses

func (pp *PrettyPrinter) ResetColorScheme()

ResetColorScheme resets colorscheme to default.

func (*PrettyPrinter) ResetOutput Uses

func (pp *PrettyPrinter) ResetOutput()

ResetOutput sets pp's output back to the default output

func (*PrettyPrinter) SetColorScheme Uses

func (pp *PrettyPrinter) SetColorScheme(scheme ColorScheme)

SetColorScheme takes a colorscheme used by all future Print calls.

func (*PrettyPrinter) SetColoringEnabled Uses

func (pp *PrettyPrinter) SetColoringEnabled(enabled bool)

func (*PrettyPrinter) SetOutput Uses

func (pp *PrettyPrinter) SetOutput(o io.Writer)

SetOutput sets pp's output

func (*PrettyPrinter) Sprint Uses

func (pp *PrettyPrinter) Sprint(a ...interface{}) string

Sprint formats given arguemnts and returns the result as string.

func (*PrettyPrinter) Sprintf Uses

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

Sprintf formats with pretty print and returns the result as string.

func (*PrettyPrinter) Sprintln Uses

func (pp *PrettyPrinter) Sprintln(a ...interface{}) string

Sprintln formats given arguemnts with newline and returns the result as string.

Package pp imports 17 packages (graph) and is imported by 303 packages. Updated 2021-01-15. Refresh now. Tools for package owners.