dump

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2020 License: MIT Imports: 6 Imported by: 85

README

Dump

This is an print debug vars util package.

Install

go get github.com/gookit/goutil/dump

Usage

run demo: go run ./dump/_examples/demo1.go

package main

import "github.com/gookit/goutil/dump"

// rum demo: go run ./dump/_examples/demo1.go
func main() {
	otherFunc1()
}

func otherFunc1() {
	dump.P(
		23,
		[]string{"ab", "cd"},
		[]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, // len > 10
		map[string]interface{}{
			"key": "val", "sub": map[string]string{"k": "v"},
		},
		struct {
			ab string
			Cd int
		}{
			"ab", 23,
		},
	)
}

You will see:

Functions

func P(vs ...interface{})
func V(vs ...interface{})
func Print(vs ...interface{})

Documentation

Overview

Package dump like fmt.Println but more clear and beautiful print data.

Index

Examples

Constants

This section is empty.

Variables

View Source
var Config = dumpConfig{
	ShowMethod: true,
	MoreLenNL:  8,
}

Config dump data settings

View Source
var Output io.Writer = os.Stdout

Output set print content to the io.Writer

Functions

func Fprint

func Fprint(skip int, w io.Writer, vs ...interface{})

Fprint like fmt.Println, but the output is clearer and more beautiful

func P

func P(vs ...interface{})

P 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.NoColor = true

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,
	},
)
Config.NoColor = false

// 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:

func Println

func Println(vs ...interface{})

Println like fmt.Println, but the output is clearer and more beautiful

func ResetConfig

func ResetConfig()

ResetConfig reset config data

func V

func V(vs ...interface{})

V like fmt.Println, but the output is clearer and more beautiful

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL