We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I ran into this when running a test that uses testify, which uses Sdump to print pretty diffs. This bug was originally reported here:
stretchr/testify#480
Here's a minimal program that reproduces the buggy behavior (also attached as .zip file):
package main
import "github.com/davecgh/go-spew/spew"
type s struct { f map[[1]byte]int }
func main() {
v1 := s{ f: map[[1]byte]int{ [1]byte{0x1}: 0, [1]byte{0x2}: 0, }, } var spewConfig = spew.ConfigState{ Indent: " ", DisablePointerAddresses: true, DisableCapacities: true, SortKeys: true, } spewConfig.Sdump(v1) // panic
}
Stack trace:
GOROOT=/usr/local/go #gosetup GOPATH=/Users/zachmu/liquidata/go-workspace #gosetup /usr/local/go/bin/go build -o /private/var/folders/gc/qlp9wrp95y59cbwc48pphkm00000gn/T/__go_build_spewbug_go__1 /Users/zachmu/liquidata/go-workspace/src/github.com/liquidata-inc/ld/dolt/go/spewbug.go #gosetup /private/var/folders/gc/qlp9wrp95y59cbwc48pphkm00000gn/T/__go_build_spewbug_go__1 #gosetup panic: reflect.Value.Interface: cannot return value obtained from unexported field or method
goroutine 1 [running]: reflect.valueInterface(0x10d4fc0, 0xc0000a4199, 0xa8, 0x1, 0x10d4fc0, 0xc0000a4198) /usr/local/go/src/reflect/value.go:990 +0x1bf reflect.Value.Interface(...) /usr/local/go/src/reflect/value.go:979 github.com/davecgh/go-spew/spew.valueSortLess(0x10d6c40, 0xc0000a4199, 0xb1, 0x10d6c40, 0xc0000a4198, 0xb1, 0x0) /Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/common.go:315 +0x183 github.com/davecgh/go-spew/spew.(*valuesSorter).Less(0xc0000d6040, 0x1, 0x0, 0x100b558) /Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/common.go:328 +0xf7 sort.insertionSort(0x111bee0, 0xc0000d6040, 0x0, 0x2) /usr/local/go/src/sort/sort.go:27 +0xc4 sort.quickSort(0x111bee0, 0xc0000d6040, 0x0, 0x2, 0x4) /usr/local/go/src/sort/sort.go:209 +0x201 sort.Sort(0x111bee0, 0xc0000d6040) /usr/local/go/src/sort/sort.go:218 +0x79 github.com/davecgh/go-spew/spew.sortValues(0xc00009a330, 0x2, 0x2, 0xc0000a2100) /Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/common.go:340 +0x70 github.com/davecgh/go-spew/spew.(*dumpState).dump(0xc0000b5eb0, 0x10dc1e0, 0xc00009a210, 0x35) /Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:388 +0x60f github.com/davecgh/go-spew/spew.(*dumpState).dump(0xc0000b5eb0, 0x10e0900, 0xc00009a210, 0x19) /Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421 +0xdca github.com/davecgh/go-spew/spew.fdump(0xc0000a2100, 0x111b480, 0xc00009a240, 0xc0000b5f78, 0x1, 0x1) /Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:465 +0x15b github.com/davecgh/go-spew/spew.(*ConfigState).Sdump(0xc0000a2100, 0xc0000b5f78, 0x1, 0x1, 0xc00006e058, 0x0) /Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/config.go:281 +0x78 main.main() spewbug.go:25 +0x10b
Process finished with exit code 2
Works fine if the SortKeys option is unspecified.
spewbug.go.zip
The text was updated successfully, but these errors were encountered:
@zachmu, thanks for the minimal example!
Sorry, something went wrong.
I just encountered this via testify as well. It would be great to apply the fix in #111 or some other fix.
No branches or pull requests
I ran into this when running a test that uses testify, which uses Sdump to print pretty diffs. This bug was originally reported here:
stretchr/testify#480
Here's a minimal program that reproduces the buggy behavior (also attached as .zip file):
package main
import "github.com/davecgh/go-spew/spew"
type s struct {
f map[[1]byte]int
}
func main() {
}
Stack trace:
GOROOT=/usr/local/go #gosetup
GOPATH=/Users/zachmu/liquidata/go-workspace #gosetup
/usr/local/go/bin/go build -o /private/var/folders/gc/qlp9wrp95y59cbwc48pphkm00000gn/T/__go_build_spewbug_go__1 /Users/zachmu/liquidata/go-workspace/src/github.com/liquidata-inc/ld/dolt/go/spewbug.go #gosetup
/private/var/folders/gc/qlp9wrp95y59cbwc48pphkm00000gn/T/__go_build_spewbug_go__1 #gosetup
panic: reflect.Value.Interface: cannot return value obtained from unexported field or method
goroutine 1 [running]:
reflect.valueInterface(0x10d4fc0, 0xc0000a4199, 0xa8, 0x1, 0x10d4fc0, 0xc0000a4198)
/usr/local/go/src/reflect/value.go:990 +0x1bf
reflect.Value.Interface(...)
/usr/local/go/src/reflect/value.go:979
github.com/davecgh/go-spew/spew.valueSortLess(0x10d6c40, 0xc0000a4199, 0xb1, 0x10d6c40, 0xc0000a4198, 0xb1, 0x0)
/Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/common.go:315 +0x183
github.com/davecgh/go-spew/spew.(*valuesSorter).Less(0xc0000d6040, 0x1, 0x0, 0x100b558)
/Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/common.go:328 +0xf7
sort.insertionSort(0x111bee0, 0xc0000d6040, 0x0, 0x2)
/usr/local/go/src/sort/sort.go:27 +0xc4
sort.quickSort(0x111bee0, 0xc0000d6040, 0x0, 0x2, 0x4)
/usr/local/go/src/sort/sort.go:209 +0x201
sort.Sort(0x111bee0, 0xc0000d6040)
/usr/local/go/src/sort/sort.go:218 +0x79
github.com/davecgh/go-spew/spew.sortValues(0xc00009a330, 0x2, 0x2, 0xc0000a2100)
/Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/common.go:340 +0x70
github.com/davecgh/go-spew/spew.(*dumpState).dump(0xc0000b5eb0, 0x10dc1e0, 0xc00009a210, 0x35)
/Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:388 +0x60f
github.com/davecgh/go-spew/spew.(*dumpState).dump(0xc0000b5eb0, 0x10e0900, 0xc00009a210, 0x19)
/Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:421 +0xdca
github.com/davecgh/go-spew/spew.fdump(0xc0000a2100, 0x111b480, 0xc00009a240, 0xc0000b5f78, 0x1, 0x1)
/Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/dump.go:465 +0x15b
github.com/davecgh/go-spew/spew.(*ConfigState).Sdump(0xc0000a2100, 0xc0000b5f78, 0x1, 0x1, 0xc00006e058, 0x0)
/Users/zachmu/liquidata/go-workspace/pkg/mod/github.com/davecgh/[email protected]/spew/config.go:281 +0x78
main.main()
spewbug.go:25 +0x10b
Process finished with exit code 2
Works fine if the SortKeys option is unspecified.
spewbug.go.zip
The text was updated successfully, but these errors were encountered: