Mock function without receiver
问题 I have the file util.go : func Foo(service *SomeService) error { return helper(service) } func helper(service *SomeService) error { ... } I'm writing unit tests using testify , starting with Foo . I want to: mock helper assert mocked helper was called 1 time I saw some promising solutions at https://stackoverflow.com/a/19168875/1661745, but not sure about them: Method 1: pass helper as parameter of Foo . My doubt: testify needs a Mock struct to AssertNumberOfCalls, and here there is no struct