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"
"time"
"github.com/Kretech/xgo/dump"
)
func main() {
// just for testing
dump.ShowFileLine1 = false
dump.DefaultWriter = os.Stdout
a := 1
a2 := &a
b := `2`
c := map[string]interface{}{b: a}
t1 := time.Unix(1500000000, 0)
t2 := &t1
s1 := []byte(`123456789012`)
s2 := [12]byte{65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76}
s3 := &s2
dump.Dump(a, a2, b, c, t1, t2, s1, s2, s3)
}
Output: a => 1 a2 => *1 b => "2" c => map[string]interface{} (len=1) { "2" => 1 } t1 => time.Time 2017-07-14 02:40:00 +0000 UTC t2 => *time.Time 2017-07-14 02:40:00 +0000 UTC s1 => []uint8 (len=12) "123456789012" s2 => [12]uint8 (len=12) "ABCDEFGHIJKL" s3 => *[12]uint8 (len=12) "ABCDEFGHIJKL"
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.
