-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gomonkey 中有异步携程时,mock的方法会失效 #158
Comments
|
Gomonkey的mock并发不安全,可以尝试一下xgo,对比可以参考这里:#157 (comment) |
有时间瞅瞅,不过测试的过程中没有并发的情况,gomonkey也不支持 |
gomonkey并发不安全指的是什么?apply patch的时候吗?其他地方似乎没有问题 apply patch也可以通过预先stw来解决 |
stw怎么执行呢?我没有看到相关的教程哈哈😆 并发不安全是因为gomoneky会修改内存中的数据,多个协程并发patch,就会出现data race,所以导致数据错乱,程序崩溃。 |
不是gomonkey自己提供的,是另外一个项目,mockey https://github.com/bytedance/mockey/blob/main/internal/monkey/mem/write.go |
算是一种hack,不过go1.23即将禁止go:linkname引用标准库未导出的函数了。所有这些hack最终都将失效。 |
func methodA(){
...
go methodB()
....
}
gomonkey.ApplyFunctionReturn(methodB) linux环境下,不生效
The text was updated successfully, but these errors were encountered: