You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
Similar to #622, having a type-safe Do() and DoAndReturn():
Makes it easier to write Do() and DoAndReturn() code with autocomplete and type checks
When functions are refactored, the type check of these functions helps identifies what tests need to be updated
Protects against runtime issues that can be effectively caught during compile time or linting.
Given the interface:
typeFoointerface {
Bar(iint64, sstring) (bbool)
}
gomock generates the following methods:
Do(finterface{})
DoAndReturn(finterface{})
Therefore, any function (even when it doesn't match the original interface's method signature) can be passed to Do() and DoAndReturn() risking a runtime error and making it difficult to refactor method signatures effectively.
Proposed Solution
Based on the example of, the following should become the signatures of Do() and DoAndReturn() of the generated mock: