Skip to content

relunctance/dump

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dump

Dump

GoDev codecov Go Report Card Sourcegraph

Dumps information about a variable . The Same as PHP:var_dump

Getting Started

Installing

go get -v github.com/relunctance/dump

Usage

Example:Dump()

import (
    "github.com/relunctance/dump"
)

func main(){
	dump.Dump(
		[]string{"a", "b", "c"},
		"abc",
		1,
		1.68,
		[]int{1, 2, 3, 4, 5},
		[]int32{1, 2, 3, 4, 5},
		map[string]string{
			"a": "1",
			"b": "2",
			"c": "3",
		},
		map[string]int{
			"a": 1,
			"b": 2,
			"c": 3,
		},
	)
}

/* returns:
[
   "a",
   "b",
   "c"
]
"abc"
1
1.68
[
   1,
   2,
   3,
   4,
   5
]
[
   1,
   2,
   3,
   4,
   5
]
{
   "a": "1",
   "b": "2",
   "c": "3"
}
{
   "a": 1,
   "b": 2,
   "c": 3
}
*/

Example:ColorDump()

import (
    "github.com/relunctance/dump"
    "github.com/fatih/color"
)

func main(){
	dump.ColorDump(
		color.New(color.FgRed).Add(color.BgHiWhite),    // with color
		[]string{"a", "b", "c"},
		"abc",
		1,
		1.68,
		[]int{1, 2, 3, 4, 5},
		[]int32{1, 2, 3, 4, 5},
		map[string]string{ "a": "1", "b": "2", "c": "3", },
		map[string]int{ "a": 1, "b": 2, "c": 3, },
	)
}

Example:P()

import (
    "github.com/relunctance/dump"
)

func main(){
	dump.P(
		[]string{"a", "b", "c"},
		"abc",
		1,
		1.68,
		[]int{1, 2, 3, 4, 5},
		[]int32{1, 2, 3, 4, 5},
		map[string]string{ "a": "1", "b": "2", "c": "3", },
		map[string]int{ "a": 1, "b": 2, "c": 3, },
	)
}

Thanks

About

Color print package for golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages