gogomock

is there a way to create a new gomock controller without NewController?


as title said, is there a way to create a new gomock controller without NewController? the comment in the package said

// NewController returns a new Controller. It is the preferred way to create a
// Controller.

I'm wondering if there is a way for creating it without the constructor?

I tried many ways, like creating it using new() and assigning the variables directly but the controller won't work


Solution

  • Type Controller has a private field expectedCalls which cannot be set outside the constructor. You need to use NewController or WithContext functions.