modulepackage
2.3.0+incompatible
Repository: https://github.com/the-redback/pp.git
Documentation: pkg.go.dev
# README
pp 
Colored pretty printer for Go language
Usage
Just call pp.Print()
.
import "github.com/k0kubun/pp"
m := map[string]string{"foo": "bar", "hello": "world"}
pp.Print(m)
API
fmt package-like functions are provided.
pp.Print()
pp.Println()
pp.Sprint()
pp.Fprintf()
// ...
API doc is available at: http://godoc.org/github.com/k0kubun/pp
Custom colors
If you require, you may change the colors (all or some) for syntax highlighting:
// Create a struct describing your scheme
scheme := pp.ColorScheme{
Integer: pp.Green | pp.Bold,
Float: pp.Black | pp.BackgroundWhite | pp.Bold,
String: pp.Yellow,
}
// Register it for usage
pp.SetColorScheme(scheme)
Look into ColorScheme struct for the field names.
If you would like to revert to the default highlighting, you may do so by calling pp.ResetColorScheme()
.
Out of the following color flags, you may combine any color with a background color and optionally with the bold parameter. Please note that bold will likely not work on the windows platform.
// Colors
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White
// Background colors
BackgroundBlack
BackgroundRed
BackgroundGreen
BackgroundYellow
BackgroundBlue
BackgroundMagenta
BackgroundCyan
BackgroundWhite
// Other
Bold
// Special
NoColor
Demo
Timeline
UserStream event
Works on windows
License
MIT License
# Functions
Errorf formats given arguments and returns it as error type.
Fatal prints given arguments and finishes execution with exit status 1.
Fatalf prints a given format and finishes execution with exit status 1.
Fatalln prints given arguments with newline and finishes execution with exit status 1.
Fprint prints given arguments to a given writer.
Fprintf prints format to a given writer.
Fprintln prints given arguments to a given writer with newline.
GetDefaultOutput returns pp's default output.
Print prints given arguments.
Printf prints a given format.
Println prints given arguments with newline.
ResetColorScheme resets colorscheme to default.
Change Print* functions' output to default one.
SetColorScheme takes a colorscheme used by all future Print calls.
Change Print* functions' output to a given writer.
Sprint formats given arguemnts and returns the result as string.
Sprintf formats with pretty print and returns the result as string.
Sprintln formats given arguemnts with newline and returns the result as string.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Bold flag for ColorScheme.
No description provided by the author
No description provided by the author
No description provided by the author
No color.
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
If the length of array or slice is larger than this, the buffer will be shorten as {...}.
If you set false to this variable, you can use pretty formatter without coloring.
WithLineInfo add file name and line information to output call this function with care, because getting stack has performance penalty.
# Structs
To use with SetColorScheme.