Documentation
¶
Index ¶
- func CallOriginal(f interface{}, args ...interface{}) []interface{}
- func CallOriginalByName(f string, args ...interface{}) []interface{}
- func GetMockFor(f interface{}) interface{}
- func Mock(src interface{}, dst interface{})
- func MockByName(src string, dst interface{})
- func RegisterFunc(fun interface{}, name string, p *int32)
- func ReloaderLoop()
- func Reset(f interface{})
- func ResetAll()
- func ResetByName(src string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallOriginal ¶
func CallOriginal(f interface{}, args ...interface{}) []interface{}
CallOriginal calls the original implementation of the function f. Note that the behaviour of recursive functions is not defined.
func CallOriginalByName ¶
func CallOriginalByName(f string, args ...interface{}) []interface{}
CallOriginalByName calls the original implementation of the function f. Note that the behaviour of recursive functions is not defined.
func GetMockFor ¶
func GetMockFor(f interface{}) interface{}
GetMockFor returns the mock that was set in Mock() method for the supplied function if such mock exists and nil otherwise.
func Mock ¶
func Mock(src interface{}, dst interface{})
Mock substitutes the src function with dst in runtime. In order to pass function pointers to methods you need to write the following expression: `(*typeName).MethodName`.
func MockByName ¶
func MockByName(src string, dst interface{})
MockByName mocks the function by it's name src. Dst is the function that should replace src.
The name of a function is formed using the following scheme:
- For plain functions it's just "package/Symbol", E.g. for `os.Open()` it would be "os/Open"
- For pointer methods it is "package/*receiverType.MethodName": E.g. for `Close` method of `*os.File` it would be "os/*File.Close"
- For value methods it is "package/receiverType.MethodName": E.g. for `IsZero` method of `time.Time` it would be "time/Time.IsZero"
func RegisterFunc ¶
RegisterFunc is a callback that is used in rewritten files to register the function so that it can be mocked. Do not use directly.
func ReloaderLoop ¶
func ReloaderLoop()
ReloaderLoop starts a loop that loads new plugins and applies patches to existing functions. Suggested usage: `go hot.ReloaderLoop()`
func Reset ¶
func Reset(f interface{})
Reset removes the mock that was set up for the function f, returning it to the original implementation. If there were no mocks set up for the function it is a noop.
func ResetByName ¶
func ResetByName(src string)
ResetByName removes the mock that was set up for the function src, returning it to the original implementation. If there were no mocks set up for the function it is a noop.
Types ¶
This section is empty.