I've recently faced a weird crash when debugging some tests that use https://github.com/stretchr/testify/mock. It turned out mock uses go-spew under the hood and it causes the tests to crash. I prepared a small program that reproduces the issue:
package main
import (
"fmt"
"github.com/davecgh/go-spew/spew"
)
type Foo struct {
value string
}
func (u Foo) String() string {
return u.value
}
type FooWrapper struct {
*Foo
}
func main() {
fmt.Println(spew.Sdump(FooWrapper{&Foo{value: "value"}}))
}
When I run the program using go run main.go it crashes with:
I've recently faced a weird crash when debugging some tests that use https://github.com/stretchr/testify/mock. It turned out
mock
uses go-spew under the hood and it causes the tests to crash. I prepared a small program that reproduces the issue:When I run the program using
go run main.go
it crashes with:Some additional notes:
len(u.value)
insideString()
before returning it, I actually see4989544637250142208
in the output.value
an empty string instead of"value"
, it does not crash, instead I see this output:u.value
insideString()
before returning it(fmt.Println(u.value)
), it does not crash, instead I see this output:Go version:
1.21.0
OS:Ubuntu 22.04.3 LTS
andmacOS 14