bytedance / mockey

a simple and easy-to-use golang mock library
Apache License 2.0
557 stars 22 forks source link

unsafe mock #7

Closed ycydsxy closed 1 year ago

ycydsxy commented 1 year ago

Is your feature request related to a problem? Please describe.

In many cases, the function has only one line or fewer:

func Foo() {
    // do nothing
}

The error "function is too short" occurs when mocking because the instructions to be inserted is longer than the target function itself.

Describe the solution you'd like

provide a MockUnsafe function instead of Mock to deal with this situation and ignore these security restrictions.

Describe alternatives you've considered

none

Additional context

It may cause some unknown problems because we may polluted the memory space which doesn't belong to the target function.