-
Notifications
You must be signed in to change notification settings - Fork 21
Add detailed internal design document #7
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
Comments
Hope for more Information about this technique. Maybe a detailed article? |
I will add materials on this issue thread to supplement the design document. |
A new gained technique: declare init bodies. Description: the following code always panics no matter you have deleted __xgo_link_generate_init_regs_body 's body or replaced it with completely new contents. The only difference with other linking names is that it is called from init. So the best practice is to not include that panic. However, in user written code there are also cases where a linked method is called from init, but they are all fine with a panic. Still needs to dig into this. func init() {
__xgo_link_generate_init_regs_body()
}
func __xgo_link_generate_init_regs_body() {
panic("failed to link __xgo_link_generate_init_regs_body")
} See d6c2b3d#diff-61c14e77880a87918b0cf686da52025d4e0abdd7b94047196c7baf56eb59ce9fR35 |
the
|
As a result, // package level func
mock.Mock(SomeFunc, interceptor)
// per-instance method
// only the bound instance `v` will be mocked
// `v` can be either a struct or an interface
mock.Mock(v.Method, interceptor)
// per-TParam generic function
// only the specified `int` version will be mocked
mock.Mock(GenericFunc[int], interceptor)
// per TParam and instance generic method
v := GenericStruct[int]
mock.Mock(v.Method, interceptor)
// closure can also be mocked
// less used, but also supported
mock.Mock(closure, interceptor) However, behind the scene, this topic deserves a good description. |
非常感谢作者开源了一个这样强大的mock工具,我想基于入门文档继续咨询一些设计与扩展相关的问题
期待作者的回复 |
The so-called IR rewriting sounds unfamiliar to people.What's it? How does it solve the problem that go-monkey suffers?How does it compare to other mock strategies?Can we dig further to employ this technique not only in mock, but also system tracing?
The text was updated successfully, but these errors were encountered: