I am trying to mock a function using GoMonkey, but I found it failed because compiler will be inline this function when program compiles, so GoMonkey can't mock it.
So how can I mock this function or how can I mock a other member's private function?
Test Code Like this:
patches := gomonkey.ApplyFunc(time.ParseInLocation, func(format string, timeStr string, cstSh *time.Location) (time.Time,error) {
return time.Time{},errors.New("error")
})
defer patches.Reset()
resp:= Example("")
So(resp, ....)
mock function
...
t, err := time.ParseInLocation(format, timeStr, cstSh)
...