Documentation ¶
Overview ¶
Package dump like fmt.Println but more pretty and beautiful print Go values.
Index ¶
- Constants
- func Config(fn func(opts *Options))
- func Format(vs ...interface{}) string
- func Fprint(w io.Writer, vs ...interface{})
- func P(vs ...interface{})
- func Print(vs ...interface{})
- func Println(vs ...interface{})
- func Reset()
- func V(vs ...interface{})
- type Dumper
- func (d *Dumper) Dump(vs ...interface{})
- func (d *Dumper) Fprint(w io.Writer, vs ...interface{})
- func (d *Dumper) Print(vs ...interface{})
- func (d *Dumper) Println(vs ...interface{})
- func (d *Dumper) ResetOptions()
- func (d *Dumper) WithOptions(fn func(opts *Options)) *Dumper
- func (d *Dumper) WithSkip(skip int) *Dumper
- func (d *Dumper) WithoutColor() *Dumper
- type Options
- type Theme
Examples ¶
Constants ¶
View Source
const ( Fnopos = 1 << iota // no position Ffunc Ffile Ffname Fline )
These flags define which print caller information
Variables ¶
This section is empty.
Functions ¶
func Format ¶
func Format(vs ...interface{}) string
Format like fmt.Println, but the output is clearer and more beautiful
func Print ¶
func Print(vs ...interface{})
Print like fmt.Println, but the output is clearer and more beautiful
Example ¶
Config(func(d *Options) { d.NoColor = true }) defer Reset() Print( 23, []string{"ab", "cd"}, []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, map[string]string{"key": "val"}, map[string]interface{}{ "sub": map[string]string{"k": "v"}, }, struct { ab string Cd int }{ "ab", 23, }, ) // Output like: // PRINT AT github.com/gookit/goutil/dump.ExamplePrint(LINE 14): // int(23) // []string{"ab", "cd"} // []int [ // 1, // 2, // 3, // 4, // 5, // 6, // 7, // 8, // 9, // 10, // 11, // ] // map[string]string { // key: "val", // } // map[string]interface {} { // sub: map[string]string{"k":"v"}, // } // struct { ab string; Cd int } { // ab: "ab", // Cd: 23, // } //
Output:
Types ¶
type Dumper ¶
type Dumper struct { *Options // contains filtered or unexported fields }
Dumper struct definition
func (*Dumper) WithOptions ¶
WithOptions for dumper
type Options ¶
type Options struct { // Output the output writer Output io.Writer // NoType dont show data type TODO NoType bool // NoColor don't with color NoColor bool // IndentLen width. default is 2 IndentLen int // IndentChar default is one space IndentChar byte // MaxDepth for nested print MaxDepth int // ShowFlag for display caller position ShowFlag int // MoreLenNL array/slice elements length > MoreLenNL, will wrap new line // MoreLenNL int // CallerSkip skip for call runtime.Caller() CallerSkip int // ColorTheme for print result. ColorTheme Theme }
Options for dump vars
Click to show internal directories.
Click to hide internal directories.