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

50 views Asked by At

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

1

There are 1 answers

1
ikamornikau On BEST ANSWER

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