Implements a deep pretty printer for Go data structures to aid in debugging

Overview

go-spew

Build Status ISC License Coverage Status

Go-spew implements a deep pretty printer for Go data structures to aid in debugging. A comprehensive suite of tests with 100% test coverage is provided to ensure proper functionality. See test_coverage.txt for the gocov coverage report. Go-spew is licensed under the liberal ISC license, so it may be used in open source or commercial projects.

If you're interested in reading about how this package came to life and some of the challenges involved in providing a deep pretty printer, there is a blog post about it here.

Documentation

GoDoc

Full go doc style documentation for the project can be viewed online without installing this package by using the excellent GoDoc site here: http://godoc.org/github.com/davecgh/go-spew/spew

You can also view the documentation locally once the package is installed with the godoc tool by running godoc -http=":6060" and pointing your browser to http://localhost:6060/pkg/github.com/davecgh/go-spew/spew

Installation

$ go get -u github.com/davecgh/go-spew/spew

Quick Start

Add this import line to the file you're working in:

import "github.com/davecgh/go-spew/spew"

To dump a variable with full newlines, indentation, type, and pointer information use Dump, Fdump, or Sdump:

spew.Dump(myVar1, myVar2, ...)
spew.Fdump(someWriter, myVar1, myVar2, ...)
str := spew.Sdump(myVar1, myVar2, ...)

Alternatively, if you would prefer to use format strings with a compacted inline printing style, use the convenience wrappers Printf, Fprintf, etc with %v (most compact), %+v (adds pointer addresses), %#v (adds types), or %#+v (adds types and pointer addresses):

spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)

Debugging a Web Application Example

Here is an example of how you can use spew.Sdump() to help debug a web application. Please be sure to wrap your output using the html.EscapeString() function for safety reasons. You should also only use this debugging technique in a development environment, never in production.

package main

import (
    "fmt"
    "html"
    "net/http"

    "github.com/davecgh/go-spew/spew"
)

func handler(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "text/html")
    fmt.Fprintf(w, "Hi there, %s!", r.URL.Path[1:])
    fmt.Fprintf(w, "<!--\n" + html.EscapeString(spew.Sdump(w)) + "\n-->")
}

func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
}

Sample Dump Output

(main.Foo) {
 unexportedField: (*main.Bar)(0xf84002e210)({
  flag: (main.Flag) flagTwo,
  data: (uintptr) <nil>
 }),
 ExportedField: (map[interface {}]interface {}) {
  (string) "one": (bool) true
 }
}
([]uint8) {
 00000000  11 12 13 14 15 16 17 18  19 1a 1b 1c 1d 1e 1f 20  |............... |
 00000010  21 22 23 24 25 26 27 28  29 2a 2b 2c 2d 2e 2f 30  |!"#$%&'()*+,-./0|
 00000020  31 32                                             |12|
}

Sample Formatter Output

Double pointer to a uint8:

	  %v: <**>5
	 %+v: <**>(0xf8400420d0->0xf8400420c8)5
	 %#v: (**uint8)5
	%#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5

Pointer to circular struct with a uint8 field and a pointer to itself:

	  %v: <*>{1 <*><shown>}
	 %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)<shown>}
	 %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)<shown>}
	%#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)<shown>}

Configuration Options

Configuration of spew is handled by fields in the ConfigState type. For convenience, all of the top-level functions use a global state available via the spew.Config global.

It is also possible to create a ConfigState instance that provides methods equivalent to the top-level functions. This allows concurrent configuration options. See the ConfigState documentation for more details.

* Indent
	String to use for each indentation level for Dump functions.
	It is a single space by default.  A popular alternative is "\t".

* MaxDepth
	Maximum number of levels to descend into nested data structures.
	There is no limit by default.

* DisableMethods
	Disables invocation of error and Stringer interface methods.
	Method invocation is enabled by default.

* DisablePointerMethods
	Disables invocation of error and Stringer interface methods on types
	which only accept pointer receivers from non-pointer variables.  This option
	relies on access to the unsafe package, so it will not have any effect when
	running in environments without access to the unsafe package such as Google
	App Engine or with the "safe" build tag specified.
	Pointer method invocation is enabled by default.

* DisablePointerAddresses
	DisablePointerAddresses specifies whether to disable the printing of
	pointer addresses. This is useful when diffing data structures in tests.

* DisableCapacities
	DisableCapacities specifies whether to disable the printing of capacities
	for arrays, slices, maps and channels. This is useful when diffing data
	structures in tests.

* ContinueOnMethod
	Enables recursion into types after invoking error and Stringer interface
	methods. Recursion after method invocation is disabled by default.

* SortKeys
	Specifies map keys should be sorted before being printed. Use
	this to have a more deterministic, diffable output.  Note that
	only native types (bool, int, uint, floats, uintptr and string)
	and types which implement error or Stringer interfaces are supported,
	with other types sorted according to the reflect.Value.String() output
	which guarantees display stability.  Natural map order is used by
	default.

* SpewKeys
	SpewKeys specifies that, as a last resort attempt, map keys should be
	spewed to strings and sorted by those strings.  This is only considered
	if SortKeys is true.

Unsafe Package Dependency

This package relies on the unsafe package to perform some of the more advanced features, however it also supports a "limited" mode which allows it to work in environments where the unsafe package is not available. By default, it will operate in this mode on Google App Engine and when compiled with GopherJS. The "safe" build tag may also be specified to force the package to build without using the unsafe package.

License

Go-spew is licensed under the copyfree ISC License.

Issues
  • Google App Engine

    Google App Engine

    Is it possible to remove the unsafe package so that your package works with Google App Engine:

    parser: bad import "unsafe" in github.com/davecgh/go-spew/spew/common.go

    opened by pjebs 23
  • Feature Request: Support printing in Go syntax

    Feature Request: Support printing in Go syntax

    Right now spew does a great job of visualizing Go data structures for debugging purposes. I think it'd be useful to be able to print the data structures that is valid Go code to recreate the structure itself.

    For instance, currently this code...

    package main
    
    import "github.com/davecgh/go-spew/spew"
    
    func main() {
        spew.Config.Indent = "\t"
    
        type Inner struct {
            Field1 string
            Field2 int
        }
        type Lang struct {
            Name  string
            Year  int
            URL   string
            Inner *Inner
        }
    
        x := Lang{
            Name: "Go",
            Year: 2009,
            URL:  "http",
            Inner: &Inner{
                Field1: "Secret!",
            },
        }
    
        spew.Dump(x)
    }
    

    Will produce:

    (main.Lang) {
        Name: (string) "Go",
        Year: (int) 2009,
        URL: (string) "http",
        Inner: (*main.Inner)(0x42166440)({
            Field1: (string) "Secret!",
            Field2: (int) 0
        })
    }
    

    But I'd like to be able to print x so that the output would be:

    Lang{
        Name: "Go",
        Year: 2009,
        URL:  "http",
        Inner: &Inner{
            Field1: "Secret!",
        },
    }
    

    And/or:

    Lang{Name: "Go", Year: 2009, URL: "http", Inner: &Inner{Field1: "Secret!"}}
    
    enhancement 
    opened by dmitshur 15
  • fatal error: stack overflow

    fatal error: stack overflow

    I used a Delve debugger and go version go1.6.2 darwin/amd64. When tried to log token's struct I got this message

    (*oauth2.token)(0xc82006cea0)(
    runtime: goroutine stack exceeds 1000000000-byte limit
    fatal error: stack overflow
    

    whereas using another method fmt.Printf I get the following

    &oauth2.token{Token:oauth2.Token{AccessToken:"(redacted)", TokenType:"", RefreshToken:"", Expiry:time.Time{sec:0, nsec:0, loc:(*time.Location)(0x8ccd80)}, raw:interface {}(nil)}}
    

    Setting the MaxDepth limit doesn't work.

    opened by bezigon 10
  • Does not spew any struct fields for me:

    Does not spew any struct fields for me:

    I have a type like this:

    type FrustumCoords struct {
        Vec2
        C, TL, TR, BL, BR Vec3
    
        x, y Vec3
    }
    

    Whether I spew.Printf or spew.Dump a variable of that type, it only spews the fields of the embedded Vec2 (which in turn has two float64 fields, X and Y), nothing else, no C, TL, TR, BL, BR..

    What now? Docs say:

    * MaxDepth
        Maximum number of levels to descend into nested data structures.
        There is no limit by default.
    

    OK I'm not setting any configs for spew anywhere, so not sure what I have to do?

    languagelimitation workaround 
    opened by metaleap 9
  • simpler, more robust bypass

    simpler, more robust bypass

    We make the bypass implementation a little simpler by inferring the flag field position from available reflect information and more robust by checking that the flags that are set actually match the semantics we expect.

    We can restrict the use of unsafe to a single function: flagField.

    opened by rogpeppe 9
  • handle map[*A]B better

    handle map[*A]B better

    I have a map[*MyStruct]OtherThing. Even with SortKeys set to true, the map ordering is non-deterministic (pointers, duh). I wonder if we could do something more heavyweight but deterministic when *MyStruct does not have a String() method? Maybe a new config option like SpewKeys which would apply the same spew conversion to each map key, then sort the resulting strings.

    I understand it's a pretty niche case, but it would be useful in our generic "hash object" logic.

    Alternatively, some way to get an error for a non-deterministic spew?

    opened by thockin 7
  • Stringer : runtime: goroutine stack exceeds 1000000000-byte limit

    Stringer : runtime: goroutine stack exceeds 1000000000-byte limit

    Hello, I want to use go-spew into String() string. For example:

    type Example struct {
        foo string
    }
    
    func (e Example) String() string {
      return spew.Sprintf("%+v", e)
    }
    

    Unfortunately, that generates:

    runtime: goroutine stack exceeds 1000000000-byte limit
    fatal error: stack overflow
    
    runtime stack:
    runtime.throw(0x55c280, 0xe)
        /usr/lib/go/src/runtime/panic.go:547 +0x90
    runtime.newstack()
        /usr/lib/go/src/runtime/stack.go:940 +0xb11
    runtime.morestack()
        /usr/lib/go/src/runtime/asm_amd64.s:359 +0x7f
    
    goroutine 1 [stack growth]:
    fmt.(*pp).argNumber(0xc826df4820, 0x0, 0x553da0, 0x3, 0x2, 0x1, 0x0, 0x0, 0x0)
        /usr/lib/go/src/fmt/print.go:1088 fp=0xc8401002b8 sp=0xc8401002b0
    fmt.(*pp).doPrintf(0xc826df4820, 0x553da0, 0x3, 0xc826dbf530, 0x1, 0x1)
        /usr/lib/go/src/fmt/print.go:1144 +0xc87 fp=0xc840100640 sp=0xc8401002b8
    fmt.Sprintf(0x553da0, 0x3, 0xc826dbf530, 0x1, 0x1, 0x0, 0x0)
        /usr/lib/go/src/fmt/print.go:203 +0x6f fp=0xc840100690 sp=0xc840100640
    github.com/davecgh/go-spew/spew.Sprintf(0x553da0, 0x3, 0xc840100730, 0x1, 0x1, 0x0, 0x0)
        .../github.com/davecgh/go-spew/spew/spew.go:126 +0x90 fp=0xc8401006e8 sp=0xc840100690
    main.Person.String(0x26, 0x5544e0, 0x6, 0x554540, 0x7, 0xc82000e0c0, 0x3, 0x3, 0x0, 0x0)
        .../src/cmd/spew/main.go:17 
    

    Do you know a elegant manner to do this ?

    Thx

    opened by jerome-laforge 6
  • Bug with go 1.4.1

    Bug with go 1.4.1

    Hi! I used go-spew in long running process and had this error:

    fatal error: unexpected signal during runtime execution
    [signal 0xb code=0x1 addr=0x1 pc=0x8069ef0]
    
    runtime stack:
    runtime.gothrow(0x8416f68, 0x2a)
            /usr/local/go/src/runtime/panic.go:503 +0x67 fp=0xb63e2f4c sp=0xb63e2f40
    runtime.sigpanic()
            /usr/local/go/src/runtime/sigpanic_unix.go:14 +0x53 fp=0xb63e2f74 sp=0xb63e2f4c
    scanblock(0x189c89e8, 0x10, 0x8438b68)
            /usr/local/go/src/runtime/mgc0.c:311 +0x840 fp=0xb63e3014 sp=0xb63e2f74
    scanframe(0xb63e30a0, 0x0, 0x1)
            /usr/local/go/src/runtime/mgc0.c:740 +0x186 fp=0xb63e3050 sp=0xb63e3014
    runtime.gentraceback(0x80520d0, 0x189c89e4, 0x0, 0x1887adc0, 0x0, 0x0, 0x7fffffff, 0xb63e30f8, 0x0, 0x0, ...)
            /usr/local/go/src/runtime/traceback.go:311 +0x5c5 fp=0xb63e30cc sp=0xb63e3050
    scanstack(0x1887adc0)
            /usr/local/go/src/runtime/mgc0.c:777 +0x1e0 fp=0xb63e3104 sp=0xb63e30cc
    markroot(0x1870a050, 0xc4)
            /usr/local/go/src/runtime/mgc0.c:553 +0xcd fp=0xb63e313c sp=0xb63e3104
    runtime.parfordo(0x1870a050)
            /usr/local/go/src/runtime/parfor.c:76 +0x99 fp=0xb63e3198 sp=0xb63e313c
    gc(0xb63e32d4)
            /usr/local/go/src/runtime/mgc0.c:1439 +0x1fb fp=0xb63e32c4 sp=0xb63e3198
    runtime.gc_m()
            /usr/local/go/src/runtime/mgc0.c:1368 +0xd2 fp=0xb63e32e4 sp=0xb63e32c4
    runtime.onM(0x18710000)
            /usr/local/go/src/runtime/asm_386.s:266 +0x50 fp=0xb63e32e8 sp=0xb63e32e4
    runtime.mstart()
            /usr/local/go/src/runtime/proc.c:818 fp=0xb63e32ec sp=0xb63e32e8
    
    
    goroutine 6662130 [garbage collection]:
    runtime.switchtoM()
            /usr/local/go/src/runtime/asm_386.s:208 fp=0x1881eae8 sp=0x1881eae4
    runtime.gogc(0x0)
            /usr/local/go/src/runtime/malloc.go:469 +0x1aa fp=0x1881eb08 sp=0x1881eae8
    runtime.mallocgc(0x10, 0x0, 0x3, 0x0)
            /usr/local/go/src/runtime/malloc.go:341 +0x2c4 fp=0x1881eb60 sp=0x1881eb08
    runtime.rawmem(0x8, 0x8)
            /usr/local/go/src/runtime/malloc.go:371 +0x38 fp=0x1881eb74 sp=0x1881eb60
    runtime.growslice(0x82e40e0, 0x1881ebd8, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0)
            /usr/local/go/src/runtime/slice.go:83 +0x210 fp=0x1881ebb4 sp=0x1881eb74
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr(0x18878b80, 0x8379ec0, 0x1882f400, 0x36)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:107 +0x65b fp=0x1881ec6c sp=0x1881ebb4
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x8379ec0, 0x1882f400, 0x36)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:259 +0xdf fp=0x1881edc4 sp=0x1881ec6c
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x82ec860, 0x18737494, 0xf5)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:382 +0xdbd fp=0x1881ef1c sp=0x1881edc4
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x837c9a0, 0x18737480, 0xf9)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:412 +0x13e2 fp=0x1881f074 sp=0x1881ef1c
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr(0x18878b80, 0x8379ec0, 0x18737480, 0x36)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:154 +0x593 fp=0x1881f12c sp=0x1881f074
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x8379ec0, 0x18737480, 0x36)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:259 +0xdf fp=0x1881f284 sp=0x1881f12c
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x837c9a0, 0x188536e0, 0xf9)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:412 +0x13e2 fp=0x1881f3dc sp=0x1881f284
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr(0x18878b80, 0x8379ec0, 0x188536e0, 0x36)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:154 +0x593 fp=0x1881f494 sp=0x1881f3dc
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x8379ec0, 0x188536e0, 0x36)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:259 +0xdf fp=0x1881f5ec sp=0x1881f494
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x837e2a0, 0x1882b560, 0xd9)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:412 +0x13e2 fp=0x1881f744 sp=0x1881f5ec
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr(0x18878b80, 0x838bc80, 0x1882b560, 0x16)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:154 +0x593 fp=0x1881f7fc sp=0x1881f744
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x838bc80, 0x1882b560, 0x16)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:259 +0xdf fp=0x1881f954 sp=0x1881f7fc
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x837f2a0, 0x18853700, 0xd9)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:412 +0x13e2 fp=0x1881faac sp=0x1881f954
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr(0x18878b80, 0x837fda0, 0x18853700, 0x16)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:154 +0x593 fp=0x1881fb64 sp=0x1881faac
    github.com/davecgh/go-spew/spew.(*dumpState).dump(0x18878b80, 0x837fda0, 0x18853700, 0x16)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:259 +0xdf fp=0x1881fcbc sp=0x1881fb64
    github.com/davecgh/go-spew/spew.fdump(0x8570060, 0xb75b8470, 0x1882aae0, 0x1881fdbc, 0x1, 0x1)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:456 +0x22c fp=0x1881fd34 sp=0x1881fcbc
    github.com/davecgh/go-spew/spew.Sdump(0x1881fdbc, 0x1, 0x1, 0x0, 0x0)
            /gopath/src/github.com/davecgh/go-spew/spew/dump.go:471 +0x8e fp=0x1881fd74 sp=0x1881fd34
    
    opened by m0sth8 6
  • Slice index out of range panic

    Slice index out of range panic

    I'm calling Sdump on a complex struct and it seems to go out of bounds on a slice:

    runtime.gopanic
    	/opt/go/src/runtime/panic.go:965
    reflect.Value.Index
    	/opt/go/src/reflect/value.go:962
    github.com/davecgh/go-spew/spew.(*dumpState).dumpSlice
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:238
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:352
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/go-spew[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:394
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:391
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dumpSlice
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:238
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:352
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dumpSlice
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:238
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:352
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421
    github.com/davecgh/go-spew/spew.(*dumpState).dumpPtr
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:154
    github.com/davecgh/go-spew/spew.(*dumpState).dump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:262
    github.com/davecgh/go-spew/spew.fdump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:465
    github.com/davecgh/go-spew/spew.Sdump
    	/code/.cache/gopath/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:480
    

    Here's the code block in value that it's hitting:

    	case Slice:
    		// Element flag same as Elem of Ptr.
    		// Addressable, indirect, possibly read-only.
    		s := (*unsafeheader.Slice)(v.ptr)
    		if uint(i) >= uint(s.Len) {
    			panic("reflect: slice index out of range")
    		}
    

    This was in prod so I'm not sure what the exact input was, but let me know if there's anything else that would be relevant.

    Thanks!

    opened by lchanglyft 0
  • Can you provide a concise version of the configuration

    Can you provide a concise version of the configuration

    Can you provide a concise version of the configuration ? remove type, length, keep only key and value

    opened by dugei 1
  • *C.struct_ABC => panic

    *C.struct_ABC => panic

    When using CGO and some pointers to C structs, spew tries to dump these and panics.

    If I change to unsafe.Pointer and add a lot of casts to my code, spew understands that unsafe.Pointer shouldn't be followed.

    I would be nice if spew can handle *C... whatever pointers too.

    opened by Robert-M-Muench 0
  • Suppress printing of nil pointers

    Suppress printing of nil pointers

    Currently if spew prints a structure that contains pointers valued as nil, it will print a line something like this:

    TransportID: (*string)(<nil>),

    Is it possible to suppress the display of pointers that have nil as a value?

    opened by objsys 0
  • Travis-ci: added support for ppc64le & update go 1.12 to 1.15

    Travis-ci: added support for ppc64le & update go 1.12 to 1.15

    Added power support for the travis.yml file with ppc64le and update latest go versions 1.12 to 1.15. This is part of the Ubuntu distribution for ppc64le. This helps us simplify testing later when distributions are re-building and re-releasing.

    opened by dthadi3 0
  • Is this lib abandoned?

    Is this lib abandoned?

    Latest commit is from 2018, despite multiple open PR's and very actively used in popular libraries like testify.

    @davecgh are you open to adding new maintainers to help keep this project alive?

    opened by jeffwidman 5
  • Move lib up to top-level

    Move lib up to top-level

    Unfortunately, go get is broken for projects lacking top-level .GO files. Could we please elevate the library code up to the top level?

    For example, place a basic version.go file denoting the library version up at go-spew/version.go, and updating the README documentation to reference the top level for go get... commands.

    opened by mcandre 0
  • Add go module for Go1.11.

    Add go module for Go1.11.

    This commit intend to add go modules to the go-spew package.

    opened by ritoon 0
  • Allow disabling address of functions

    Allow disabling address of functions

    Structs with function types output the function address, even with DisablePointerAddresses: true. Perhaps that makes sense, since a function type isn't really a pointer. But it would be great to be able to disable these addresses. To reproduce:

    package main
    
    import (
    	"github.com/davecgh/go-spew/spew"
    )
    
    func main() {
    	cf := spew.ConfigState{
    		DisablePointerAddresses: true,
    	}
    	x := struct {
    		fn func()
    	}{
    		fn: func() {},
    	}
    	cf.Dump(x)
    }
    

    Which produces the following output:

    (struct { fn func() }) {
    fn: (func()) 0x4c0020
    }
    

    playground

    opened by flimzy 0
Owner
Dave Collins
Dave Collins
Colored pretty printer for Go language

pp Colored pretty printer for Go language Usage Just call pp.Print(). import "github.com/k0kubun/pp" m := map[string]string{"foo": "bar", "hello": "w

Takashi Kokubun 1.2k Dec 3, 2021
Quick and dirty debugging output for tired Go programmers

q q is a better way to do print statement debugging. Type q.Q instead of fmt.Printf and your variables will be printed like this: Why is this better t

Ryan Boehning 1.3k Dec 3, 2021
Package httpretty prints the HTTP requests you make with Go pretty on your terminal.

httpretty Package httpretty prints the HTTP requests of your Go programs pretty on your terminal screen. It is mostly inspired in curl's --verbose mod

Henrique Vicente 243 Dec 1, 2021
🪵 A dead simple, pretty, and feature-rich logger for golang

?? lumber ?? A dead simple, pretty, and feature-rich logger for golang ?? Install ?? Logging Functions lumber.Success() lumber.Info() lumber.Debug() l

Matt Gleich 47 Nov 29, 2021
A customized GORM logger that implements the appropriate interface and uses Logrus to output logs

CryptoMath GORM Logger A customized GORM logger that implements the appropriate interface and uses Logrus to output logs. Install go get github.com/ma

Crypto Math 0 Nov 6, 2021
Package logging implements a logging infrastructure for Go

Golang logging library Package logging implements a logging infrastructure for Go. Its output format is customizable and supports different logging ba

Luke Zhang 0 Nov 10, 2021
A flexible process data collection, metrics, monitoring, instrumentation, and tracing client library for Go

Package monkit is a flexible code instrumenting and data collection library. See documentation at https://godoc.org/gopkg.in/spacemonkeygo/monkit.v3 S

Space Monkey Go 458 Nov 28, 2021
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

The open-source platform for monitoring and observability. Grafana allows you to query, visualize, alert on and understand your metrics no matter wher

Grafana Labs 45.2k Dec 4, 2021
Open source framework for processing, monitoring, and alerting on time series data

Kapacitor Open source framework for processing, monitoring, and alerting on time series data Installation Kapacitor has two binaries: kapacitor – a CL

InfluxData 2.1k Dec 4, 2021
Golang beautify data display for Humans

Golang beautify data display for Humans English 简体中文 Usage Examples package main import ( ffmt "gopkg.in/ffmt.v1" ) func main() { example() } typ

ffmt 244 Nov 19, 2021
pprof is a tool for visualization and analysis of profiling data

Introduction pprof is a tool for visualization and analysis of profiling data. pprof reads a collection of profiling samples in profile.proto format a

Google 4.9k Nov 30, 2021
Very simple charts with some debug data for Go programs

debugcharts Go memory debug charts. This package uses Plotly chart library. It is open source and free for use. Installation go get -v -u github.com/m

Marko Kevac 460 Dec 3, 2021
Visualise Go program GC trace data in real time

This project is no longer maintained I'm sorry but I do not have the bandwidth to maintain this tool. Please do not send issues or PRs. Thank you. gcv

Dave Cheney 1k Nov 24, 2021
Parametrized JSON logging library in Golang which lets you obfuscate sensitive data and marshal any kind of content.

Noodlog Summary Noodlog is a Golang JSON parametrized and highly configurable logging library. It allows you to: print go structs as JSON messages; pr

Gyoza Tech 34 Nov 24, 2021
Interfaces for LZ77-based data compression

Pack Interfaces for LZ77-based data compression. Introduction Many compression libraries have two main parts: Something that looks for repeated sequen

Andy Balholm 3 Oct 19, 2021
mtail - extract internal monitoring data from application logs for collection into a timeseries database

mtail - extract internal monitoring data from application logs for collection into a timeseries database mtail is a tool for extracting metrics from a

Google 3k Dec 4, 2021
Go Huobi Market Price Data Monitor

火币(Huobi)价格监控 由于部分交易对火币官方未提供价格监控,因此写了个小程序,长期屯币党可以用它来提醒各种现货价格。 该工具只需要提前安装Go环境和Redis即可。 消息推送使用的「钉钉」,需要提前配置好钉钉机器人(企业群类型、带webhook的机器人)。 使用方法 下载本项目 拷贝根目录下

ROC 2 Sep 24, 2021
Beta tool to normalize Orbit member data

Orbit Normalize Member Data Thanks for checking out my handy tool to work with Orbit's api. Everything is written in go and will continue to be update

Peter ONeill 2 Sep 16, 2021
Secure logger in Go to avoid output sensitive data in log

zlog A main distinct feature of zlog is secure logging that avoid to output secret/sensitive values to log. The feature reduce risk to store secret va

Masayoshi Mizutani 16 Dec 5, 2021