Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( Zero = `<zero>` Nil = "<nil>" )
Variables ¶
View Source
var ( // uint8(97) => 'a' OptShowUint8AsChar = true // []uint8{'a','b'} => "ab" OptShowUint8sAsString = true // 按字典序显示map.keys OptSortMapKeys = true )
View Source
var ( MaxSliceLen = 32 MaxMapLen = 32 SepKv = " => " StringQuota = `"` )
View Source
var Disable = false
disable dump in global scope use it in production
Functions ¶
func Dump ¶
func Dump(args ...interface{})
Example ¶
package main
import (
"os"
"github.com/Kretech/xgo/dump"
)
func main() {
// just for testing
dump.ShowFileLine1 = false
dump.DefaultWriter = os.Stdout
a := 1
b := `2`
c := map[string]interface{}{b: a}
dump.Dump(a, b, c)
}
Output: a => 1 b => "2" c => map[string]interface{} (len=1) { "2" => 1 }
Types ¶
type CliDumper ¶
type CliDumper struct {
// contains filtered or unexported fields
}
func NewCliDumper ¶
Example ¶
package main
import (
"os"
)
func main() {
a := 1
b := `2`
ShowFileLine1 = false
DefaultWriter = os.Stdout
g1 := NewCliDumper(`g1`)
g1.Dump(a, b)
g2 := MyPackage{MyDump: MyDump}
g2.MyDump(a, b)
}
// MyPackage mock the package name. so we can called it by `x.y()`
type MyPackage struct {
MyDump func(...interface{})
}
func MyDump(args ...interface{}) {
_g := NewCliDumper(`g2`) // means package name
_g.DepthDump(1, args...)
}
Output: a => 1 b => "2" a => 1 b => "2"
Click to show internal directories.
Click to hide internal directories.
