gomonkey icon indicating copy to clipboard operation
gomonkey copied to clipboard

gomonkey is a library to make monkey patching in unit tests easy

Results 67 gomonkey issues
Sort by recently updated
recently updated
newest added

![Image](https://github.com/user-attachments/assets/00975351-ba2a-414a-9971-005789695b0d)

请问ApplyPrivateMethod方法什么时候可以使用,或者能推荐些好方法吗

理论上支持修改常量吗?

``` package inner type B struct { a } type a struct { } func (a *a) Get(key string) string { return "6666" } ``` 这种情况下如何mock Get方法

## Good case * main.go ```golang package main import ( "io" "bytes" // "github.com/sirupsen/logrus" ) type A struct {} func (a *A) exec( stdout io.Writer, stderr io.Writer, stdin io.Reader, paramList...

## 环境 MacOS: 14.6 GO版本: go1.21.13 (也测试了go1.18版本也有问题) M3芯片 gomonkey版本: v2.12.0 ## 问题描述 在一个测试用例中对同一个函数进行打桩、取消、再打桩,后续的打桩可能会失败。以下为测试代码,可以直接拷贝执行验证的 ``` golang type funcValue struct { _ uintptr p unsafe.Pointer } func getPointer(v reflect.Value) unsafe.Pointer { return...