Documentation ¶
Overview ¶
Package dump like fmt.Println but more pretty and beautiful print Go values.
Index ¶
- Constants
- func Clear(vs ...any)
- func Config(fns ...OptionFunc)
- func Format(vs ...any) string
- func Fprint(w io.Writer, vs ...any)
- func NoLoc(vs ...any)
- func P(vs ...any)
- func Print(vs ...any)
- func Println(vs ...any)
- func Reset()
- func Reset2()
- func V(vs ...any)
- type Dumper
- func (d *Dumper) Dump(vs ...any)
- func (d *Dumper) Fprint(w io.Writer, vs ...any)
- func (d *Dumper) Print(vs ...any)
- func (d *Dumper) Println(vs ...any)
- func (d *Dumper) ResetOptions()
- func (d *Dumper) WithOptions(fns ...OptionFunc) *Dumper
- func (d *Dumper) WithSkip(skip int) *Dumper
- func (d *Dumper) WithoutColor() *Dumper
- type OptionFunc
- 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 Print ¶
func Print(vs ...any)
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]any{ "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 ¶ added in v0.3.0
type Dumper struct { *Options // contains filtered or unexported fields }
Dumper struct definition
func NewWithOptions ¶ added in v0.3.14
func NewWithOptions(fns ...OptionFunc) *Dumper
NewWithOptions create
func (*Dumper) ResetOptions ¶ added in v0.3.0
func (d *Dumper) ResetOptions()
ResetOptions for dumper
func (*Dumper) WithOptions ¶ added in v0.3.0
func (d *Dumper) WithOptions(fns ...OptionFunc) *Dumper
WithOptions for dumper
func (*Dumper) WithoutColor ¶ added in v0.3.10
WithoutColor for dumper
type OptionFunc ¶ added in v0.6.1
type OptionFunc func(opts *Options)
OptionFunc type
func WithCallerSkip ¶ added in v0.6.1
func WithCallerSkip(skip int) OptionFunc
WithCallerSkip on print caller position information.
func WithoutOutput ¶ added in v0.6.1
func WithoutOutput(out io.Writer) OptionFunc
WithoutOutput setting.
func WithoutPosition ¶ added in v0.6.1
func WithoutPosition() OptionFunc
WithoutPosition dont print call dump position information.
type Options ¶ added in v0.3.0
type Options struct { // Output the output writer Output io.Writer // NoType don't 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 // CallerSkip skip for call runtime.Caller() CallerSkip int // ColorTheme for print result. ColorTheme Theme // SkipNilField value dump on map, struct. SkipNilField bool // SkipPrivate field dump on struct. SkipPrivate bool // BytesAsString dump handle. BytesAsString bool }
Options for dumper
Click to show internal directories.
Click to hide internal directories.