Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fp ¶
Fp prints dumped your specified data with colored and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
Example ¶
package main import ( "bytes" "fmt" "github.com/Code-Hex/dd/p" ) func main() { // prints simple string literal. var buf bytes.Buffer p.Fp(&buf, "Hello, World") fmt.Print(buf.String()) }
Output: �[38;5;186m"Hello, World"�[0m
func P ¶
P prints dumped your specified data with colored. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
Example ¶
package main import ( "github.com/Code-Hex/dd/p" ) func main() { // prints simple string literal. p.P("Hello, World") }
Output: �[38;5;186m"Hello, World"�[0m
Types ¶
type OptionFunc ¶
type OptionFunc func(opts *options)
OptionFunc is type of an option for any printers.
func WithDumpOptions ¶
func WithDumpOptions(ddOpts ...dd.OptionFunc) OptionFunc
WithDumpOptions is an option to append options of dd.Dump function.
func WithFormatter ¶ added in v1.0.1
func WithFormatter(formatter chroma.Formatter) OptionFunc
WithFormatter is an option to set formatter of the terminal output. Default will be set TTY256(256-colour) formatter.
Available chroma built-in formatters: https://pkg.go.dev/github.com/alecthomas/chroma/formatters
func WithStyle ¶
func WithStyle(style *chroma.Style) OptionFunc
WithStyle is an option to set style of the syntax highlighting. Default will be set Monokai style.
Available themes: https://pkg.go.dev/github.com/alecthomas/chroma/styles
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer is a printer.
func (*Printer) Fp ¶
Fp prints dumped your specified data with colored and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
Example ¶
package main import ( "bytes" "fmt" "github.com/Code-Hex/dd/p" "github.com/alecthomas/chroma/styles" ) func main() { // prints simple string literal. var buf bytes.Buffer p.New(p.WithStyle(styles.Dracula)).Fp(&buf, "Hello, World") fmt.Print(buf.String()) }
Output: �[38;5;228m"Hello, World"�[0m
func (*Printer) P ¶
P prints dumped your specified data with colored. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
Example ¶
package main import ( "github.com/Code-Hex/dd/p" "github.com/alecthomas/chroma/styles" ) func main() { // prints simple string literal. p.New(p.WithStyle(styles.Dracula)).P("Hello, World") }
Output: �[38;5;228m"Hello, World"�[0m