Open grovecai opened 1 year ago
Go Version: go version go1.18.2 darwin/amd64 MacOS version: macOS Monterey, version 12.3.1, Intel gomockey version: v2.9.0
Sample code
package go_play import ( "fmt" "github.com/agiledragon/gomonkey/v2" "testing" ) type Dummy interface { Get(a string) string } type dummy struct { } func (t *dummy) Get(a string) string { return "prefix: " + a } func Test_go(t *testing.T) { patches := gomonkey.NewPatches() defer patches.Reset() patches.ApplyMethod(&dummy{}, "Get", func(_ Dummy, in string) string { fmt.Println("IN: " + in) //Panic return "dummy" }) ret := (&dummy{}).Get("hello") fmt.Printf("Actual: " + ret) }
Panic with -gcflags=all=-l No Panic with -gcflags=-l, but fmt.Println("IN: " + in) not works as expected, only output IN:
fmt.Println("IN: " + in)
IN:
Go Version: go version go1.18.2 darwin/amd64 MacOS version: macOS Monterey, version 12.3.1, Intel gomockey version: v2.9.0
Sample code