agiledragon / gomonkey

gomonkey is a library to make monkey patching in unit tests easy
MIT License
1.93k stars 178 forks source link

有没有方式支持一个私有接收者的方法? #69

Closed lockdown56 closed 2 years ago

lockdown56 commented 2 years ago

比如如下方法

package student

var Student = student{}

type student struct {}

func (s student) GetName() {
    return "zhangsan"
}
manchurio commented 2 years ago

作者说 1.14, 1.15, 1.16 支持了私有方法, 但我是win10 amd64, 实测不行

manchurio commented 2 years ago

收回我刚才的话, 现在1.17以下可以支持,需要用gomonkey.ApplyPrivateMethod 这个方法

lockdown56 commented 2 years ago

收回我刚才的话, 现在1.17以下可以支持,需要用gomonkey.ApplyPrivateMethod 这个方法

需要升级到2.3