123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- package spew_test
- import (
- "fmt"
- "github.com/davecgh/go-spew/spew"
- )
- type Flag int
- const (
- flagOne Flag = iota
- flagTwo
- )
- var flagStrings = map[Flag]string{
- flagOne: "flagOne",
- flagTwo: "flagTwo",
- }
- func (f Flag) String() string {
- if s, ok := flagStrings[f]; ok {
- return s
- }
- return fmt.Sprintf("Unknown flag (%d)", int(f))
- }
- type Bar struct {
- data uintptr
- }
- type Foo struct {
- unexportedField Bar
- ExportedField map[interface{}]interface{}
- }
- func ExampleDump() {
-
-
-
- bar := Bar{uintptr(0)}
- s1 := Foo{bar, map[interface{}]interface{}{"one": true}}
- f := Flag(5)
- b := []byte{
- 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
- 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
- 0x31, 0x32,
- }
-
- spew.Dump(s1, f, b)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- func ExamplePrintf() {
-
- ui8 := uint8(5)
- pui8 := &ui8
- ppui8 := &pui8
-
- type circular struct {
- ui8 uint8
- c *circular
- }
- c := circular{ui8: 1}
- c.c = &c
-
- spew.Printf("ppui8: %v\n", ppui8)
- spew.Printf("circular: %v\n", c)
-
-
-
- }
- func ExampleConfigState() {
-
-
- scs := spew.ConfigState{Indent: "\t"}
-
- v := map[string]int{"one": 1}
- scs.Printf("v: %v\n", v)
- scs.Dump(v)
-
-
-
-
-
- }
- func ExampleConfigState_Dump() {
-
-
-
- scs := spew.ConfigState{Indent: "\t"}
- scs2 := spew.ConfigState{Indent: " "}
-
- bar := Bar{uintptr(0)}
- s1 := Foo{bar, map[interface{}]interface{}{"one": true}}
-
- scs.Dump(s1)
- scs2.Dump(s1)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- func ExampleConfigState_Printf() {
-
-
-
-
- scs := spew.NewDefaultConfig()
- scs2 := spew.NewDefaultConfig()
- scs.DisableMethods = true
-
-
-
-
- f := flagTwo
-
- scs.Printf("f: %v\n", f)
- scs2.Printf("f: %v\n", f)
-
-
-
- }
|