Documentation
¶
Index ¶
- Variables
- func CallOld()
- func Mock(fn interface{}, interceptor Interceptor) func()
- func MockByName(pkgPath string, funcName string, interceptor Interceptor) func()
- func MockMethodByName(instance interface{}, method string, interceptor Interceptor) func()
- func Patch(fn interface{}, replacer interface{}) func()
- func PatchByName(pkgPath string, funcName string, replacer interface{}) func()
- func PatchMethodByName(instance interface{}, method string, replacer interface{}) func()
- type Interceptor
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCallOld = errors.New("mock: call old")
a marker to indicate the original function should be called
Functions ¶
func Mock ¶
func Mock(fn interface{}, interceptor Interceptor) func()
Mock setup mock on given function `fn`. `fn` can be a function or a method, if `fn` is a method, only the bound instance will be mocked, other instances are not affected. The returned function can be used to cancel the passed interceptor.
func MockByName ¶
func MockByName(pkgPath string, funcName string, interceptor Interceptor) func()
func MockMethodByName ¶
func MockMethodByName(instance interface{}, method string, interceptor Interceptor) func()
Can instance be nil?
func Patch ¶
func Patch(fn interface{}, replacer interface{}) func()
Patch replaces `fn` with `replacer` in current goroutine. You do not have to manually clean up the replacer, as xgo will automatically clear the replacer when current gorotuine exits. However, if you want to clear the replacer earlier, this function returns a clean up function that can be used to clear the replacer.
func PatchByName ¶
func PatchMethodByName ¶
func PatchMethodByName(instance interface{}, method string, replacer interface{}) func()
Types ¶
Click to show internal directories.
Click to hide internal directories.