Closed mmccto1500 closed 2 years ago
change
patchMethodOne := gomonkey.ApplyMethod(reflect.TypeOf(mOne), "Test",
func(a int, b string) error {
// this is patch part
return nil
})
to
patchMethodOne := gomonkey.ApplyMethod(reflect.TypeOf(mOne), "Test",
func(ss *sampleStruct, a int, b string) error {
// this is patch part
return nil
})
change
patchMethodOne := gomonkey.ApplyMethod(reflect.TypeOf(mOne), "Test", func(a int, b string) error { // this is patch part return nil })
to
patchMethodOne := gomonkey.ApplyMethod(reflect.TypeOf(mOne), "Test", func(ss *sampleStruct, a int, b string) error { // this is patch part return nil })
Smart chocie! It seems that the "double type" function needs the receiver itself as the first argument. This perfectly solve my problem, thks:)
My code:
This code will bring out an error which indicates the following content:
panic: target type(func(*sampleStruct, a int, b string) error) and double type(func(a int, b string) error) are different
Is there any idea about this problem?