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

Related tags

go-spew
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]-0.20180830191138-d8f796af33cc/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: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/go-[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
Automatically generate RESTful API documentation with Swagger 2.0 for Go.

Automatically generate RESTful API documentation with Swagger 2.0 for Go.

Swaggo 4.9k Oct 22, 2021
webbased debugging for Go programs

Hopwatch, a debugging tool for Go Hopwatch is a simple tool in HTML5 that can help debug Go programs. It works by communicating to a WebSockets based

Ernest Micklei 257 Oct 8, 2021
📦 Package Node.js applications into executable binaries 📦

caxa ?? Package Node.js applications into executable binaries ?? Support Recurring support on Patreon: https://patreon.com/leafac One-time support on

Leandro Facchinetti 98 Oct 14, 2021
Go structure annotations that supports encoding and decoding; similar to C-style bitfields. Supports bitfield packing, self-describing layout parameters, and alignment.

STRUCTure EXtensions structex provides annotation rules that extend Go structures for implementation of encoding and decoding of byte backed data fram

Hewlett Packard Enterprise 43 Oct 5, 2021
Martian is a library for building custom HTTP/S proxies

Martian Proxy Martian Proxy is a programmable HTTP proxy designed to be used for testing. Martian is a great tool to use if you want to: Verify that a

Google 1.6k Oct 19, 2021
GUI frontend for Delve

GUI frontend for Delve

Alessandro Arzilli 989 Oct 18, 2021
GAPID: Graphics API Debugger

GAPID: Graphics API Debugger

Google 1.9k Oct 17, 2021
Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.

gore Yet another Go REPL that works nicely. Featured with line editing, code completion, and more. (Screencast taken with cho45/KeyCast) Usage gore Af

Hironao OTSUBO 4.3k Oct 16, 2021
Reload a specified go program automatically by monitoring a directory.

gowatcher A bash script to automatically reload a go program when .go or .html files change in the monitored directory. It uses inotify. Installation

Nick Janetakis 16 Jul 7, 2020
NoColor — validate the architecture of your PHP project

NoColor is an architecture validation tool based on the concept of colored functions. This concept was originally invented for KPHP and later exposed as a separate tool to be used in regular PHP projects.

VK.com 126 Sep 16, 2021
go-pry - an interactive REPL for Go that allows you to drop into your code at any point.

go-pry go-pry - an interactive REPL for Go that allows you to drop into your code at any point. Example Usage Install go-pry go get github.com/d4l3k/g

Tristan Rice 2.7k Oct 22, 2021
Visualize call graph of a Go program using Graphviz

go-callvis go-callvis is a development tool to help visualize call graph of a Go program using interactive view. Introduction The purpose of this tool

Ondrej Fabry 3.6k Oct 24, 2021
A node.js version management utility for Windows. Ironically written in Go.

The npm/Microsoft/Google recommended Node.js version manager for Windows. This is not the same thing as nvm. The original nvm is a completely separate

Corey Butler 17.7k Oct 23, 2021
🔥 Continuous profiling platform — debug performance issues in your code!

Pyroscope is an open source continuous profiling platform.

Pyroscope 4.5k Oct 22, 2021
(Experimental) Go library for multi-platform clipboard.

clipboard This is a multi-platform clipboard library in Go. Abstract This is clipboard library in Go, which runs on multiple platforms. External clipb

Tsuji Daishiro 62 Aug 28, 2021
go/template is a tool for jumpstarting production-ready Golang projects quickly.

go/template go/template provides a blueprint for production-ready Go project layouts. Credit to Renée French for the Go Gopher logo Credit to Go Autho

Schwarz IT 25 Oct 16, 2021
go-watcher 是一款实现 Golang 源码热重启的工具

go-watcher 是一款实现 Golang 源码热重启的工具,可替换 go run 命令执行任意 main 入口程序,包括参数

null 11 Jul 23, 2021
golang feature toggle library - a library to help make golang feature toggling clean and easy

toggle supports env_variable backed toggling. It can also be updated via a pubsub interface (tested w/ redis) 2 engines for toggle backing are include

John Calabrese 23 Aug 4, 2021
Golang实现的基于beego框架的接口在线文档管理系统

MinDoc 是一款针对IT团队开发的简单好用的文档管理系统。 MinDoc 的前身是 SmartWiki 文档系统。SmartWiki 是基于 PHP 框架 laravel 开发的一款文档管理系统。因 PHP 的部署对普通用户来说太复杂,所以改用 Golang 开发。

Minho 5.2k Oct 20, 2021