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.

Comments
  • 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
  • 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
  • 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
  • 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
  • Dump without showing pointer addresses

    Dump without showing pointer addresses

    Hi,

    I'd like to use spew in combination with a text diff pkg to show useful error messages when deep equality checks fail in my test cases. Ideally I'd like to have the same output as Dump(), but without the pointer addresses showing. Would you be interested in a patch for this? I'd be happy to propose an API for it first or take a suggestion from you.

    Cheers, Felix

    opened by felixge 6
  • Displaying len and cap

    Displaying len and cap

    It would handy if types that had len and cap were spewed with their length and capacity.

    I propose the following output, which keeps the type separate from the length and possibly cap as well:

    For slices:

    ([]string) (len=2 cap=10) {
     (string) "Hello",
     (string) "世界"
    }
    

    Maps:

    (map[string]bool) (len=2) {
     (string) "Hello": (bool) true,
     (string) "世界": (bool) false
    }
    

    Strings:

    (string) (len=13) "Hello, 世界"
    

    Channels:

    (chan string) (len=2 cap=10) 0xc20804e600
    

    Although the len and cap functions are defined for arrays, spewing their results is less useful as both are equal to the array size regardless. Displaying it anyways may be desirable for consistancy, however.

    opened by jrick 6
  • Add support for limited mode without unsafe pkg.

    Add support for limited mode without unsafe pkg.

    This pull request adds support for compiling spew without the unsafe package. When compiled without the unsafe package, some of the more advanced features such as invoking stringers on pointers from non-pointer variables and unexported struct fields are not available.

    By default, spew will be compiled in the limited mode for Google App Engine since the unsafe package is not available there. Additionally, spew can be compiled without the unsafe package manually by specifying the disableunsafe build tag.

    Finally, a new package-level constant named UnsafeDisabled has been exposed which can be used to programmatically determine if spew was compiled with access to the unsafe package.

    opened by davecgh 5
  • Override String function not works with anonymous struct param

    Override String function not works with anonymous struct param

    example code

    func main() {
    	a := A{
    		Tag: "tag-A",
    		Num: 1,
    		InA: InA{
    			Id:   100,
    			Type: "test",
    		},
    	}
    	spew.Dump(a)
    }
    
    type A struct {
    	Tag string
    	Num int
    	InA
    }
    
    type InA struct {
    	Id   int
    	Type string
    }
    
    func (t InA) String() string {
    	return t.Type
    }
    

    unexpected output

    (main.A) test
    
    opened by rsgok 1
  • Custom `String()` method of maps got invalid receiver value

    Custom `String()` method of maps got invalid receiver value

    Repro:

    package main
    
    import (
    	"fmt"
    
    	"github.com/davecgh/go-spew/spew"
    )
    
    type X map[int]int
    
    func (x X) String() string {
    	return fmt.Sprintf("{M1:%d}", len(x))
    }
    
    func main() {
    	spew.Dump(X{1: 2})
    }
    

    Output:

    (main.X) (len=1) (PANIC=runtime error: invalid memory address or nil pointer dereference){
     (int) 1: (int) 2
    }
    

    Panic occures when taking the len() of the receiver x, which is an invalid pointer.

    This happens on all versions of go I installed (1.16 to 1.18).

    opened by chenzhuoyu 2
  • Support option to avoid printing duplicate values

    Support option to avoid printing duplicate values

    Currently if there are multiple references to a pointer, the entire contents of it are printed each time (unless it's a recursive reference).

    This can result in unnecessarily large and hard to read output when an object is shared in many places.

    In one recent example, the output was 28MB, but when I changed the code to avoid printing duplicates (by removing the delete(d.pointers, k) line), the output dropped to 280KB, a factor of 100x difference.

    This is not necessarily something that would be a good idea to enable by default, because it would require using O(n) memory to keep track of all pointers seen so far, but ISTM that it would be nice to be able to enable de-duplication as an option, at any rate.

    opened by rogpeppe 0
  • github.com/davecgh/go-spew/spew is not a main package

    github.com/davecgh/go-spew/spew is not a main package

    go install github.com/davecgh/go-spew/[email protected] package github.com/davecgh/go-spew/spew is not a main package

    how can i handle with this? i'm totally new to linux Ubuntu. My go version is go version go1.18.2 linux/amd64

    opened by bitt69 0
  • 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/[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]c/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
Owner
Dave Collins
Dave Collins
Implements a deep pretty printer for Go data structures to aid in debugging

go-spew 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

Dave Collins 5.4k Jan 9, 2023
Implements a deep pretty printer for Go data structures to aid in debugging

spew Spew implements a deep pretty printer for Go data structures to aid in debugging. A comprehensive suite of tests with 100% test coverage is provi

null 94 Dec 25, 2022
Litter is a pretty printer library for Go data structures to aid in debugging and testing.

Litter Litter is a pretty printer library for Go data structures to aid in debugging and testing. Litter is provided by Sanity: The Headless CMS Const

Sanity 1.4k Dec 28, 2022
💻 PTerm | Pretty Terminal Printer A golang module to print pretty text

✨ PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more ?? It's completely configurable and 100% cross-platform compatible.

null 3.1k Jan 1, 2023
Netpoltool - CLI evaluation of Kubernetes NetworkPolicys with detailed output to aid debugging.

netpoltool CLI evaluation of Kubernetes NetworkPolicys with detailed output helpful for debugging. Given source and destination pods, identify the Net

Christopher Heriot 0 Jan 8, 2022
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.5k Dec 29, 2022
Fast Color JSON Marshaller + Pretty Printer for Golang

ColorJSON: The Fast Color JSON Marshaller for Go What is this? This package is based heavily on hokaccha/go-prettyjson but has some noticible differen

Tyler Brock 117 Dec 19, 2022
Spice.ai is an open source, portable runtime for training and using deep learning on time series data.

Spice.ai Spice.ai is an open source, portable runtime for training and using deep learning on time series data. ⚠️ DEVELOPER PREVIEW ONLY Spice.ai is

Spice.ai 774 Dec 15, 2022
Unified diff parser and printer for Go

go-diff Diff parser and printer for Go. Installing go get -u github.com/sourcegraph/go-diff/diff Usage It doesn't actually compute a diff. It only rea

Sourcegraph 381 Dec 14, 2022
Go-banner-printer - This library is to simply print a ASCII banner when you start the application

This library is to simply print a ASCII banner when you start the application.

Sathesh Sivashanmugam 1 Jan 18, 2022
Capture packet request/response pairs for a port and/or IP to aid in Network protocol based Nuclei Templates creation.

network-fingerprint Capture packet request/response pairs for a port and/or IP to aid in Network protocol based Nuclei Templates creation. Resources I

ProjectDiscovery 45 Nov 15, 2022
A library to aid unittesting code that uses Golang's Github SDK

go-github-mock A library to aid unittesting code that uses Golang's Github SDK Installation go get github.com/migueleliasweb/go-github-mock Features C

Miguel Elias dos Santos 56 Dec 30, 2022
How fast could I write tic tac toe in Go, while not knowing Go, but with the aid of GitHub Copilot?

tictactoe-go-with-copilot How fast could I write tic tac toe in Go, while not knowing Go, but with the aid of GitHub Copilot? This took me about 30 mi

null 0 Dec 9, 2021
mock server to aid testing the jaguar-java client API

stripe-mock stripe-mock is a mock HTTP server that responds like the real Stripe API. It can be used instead of Stripe's test mode to make test suites

knr.data 1 Dec 24, 2021
Various Dungeons and Dragons Tools. Written in go as an aid to learning the language.

dnd_tools Various Dungeons and Dragons Tools. Written in go as an aid to learning the language. Some tools are generic, while others will target eithe

SREiously 0 Jan 28, 2022
Gotabulate - Easily pretty-print your tabular data with Go

Gotabulate - Easily pretty-print tabular data Summary Go-Tabulate - Generic Go Library for easy pretty-printing of tabular data. Installation go get g

Vadim Kravcenko 294 Dec 27, 2022
fonet is a deep neural network package for Go.

fonet fonet is a deep neural network package for Go. It's mainly created because I wanted to learn about neural networks and create my own package. I'

Barnabás Pataki 71 Oct 27, 2022
Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs

go-testdeep Extremely flexible golang deep comparison, extends the go testing package. Latest news Synopsis Description Installation Functions Availab

Maxime Soulé 334 Dec 22, 2022
The Cloud Posse Terraform Provider for various utilities (E.g. deep merging)

terraform-provider-utils Terraform provider to add additional missing functionality to Terraform This project is part of our comprehensive "SweetOps"

Cloud Posse 71 Jan 7, 2023
A tools to find the path of a specific key in deep nested JSON.

如何快速从深层嵌套 JSON 中找到特定的 Key #公众号 在爬虫开发的过程中,我们经常遇到一些 Ajax 加载的接口会返回 JSON 数据。

kingname 56 Dec 13, 2022