I have started using gomock to create mock objects for unit testing. Gomock requires that that I run the mockgen
command with certain argument in order to generate code for the mock. This needs to be done again every time the interfaces that is being mocked changes. I therefore thought it might make sense to have go build
run mockgen
with the appropriate arguments.
Is there a way to have go build
to run a script or shell command before building a package?
If not, how do you generate your mocks and keep them up to date?