Only rewrite output files if changes are needed.
Author: sodulCreated Dec 10, 2021Updated Mar 28, 2023
Labelshelp wantedtype: feature request
Actual behavior We have a fairly large project and running mockgen takes several minutes. During that time all of the generated mock files get deleted and rewritten. This causes 2 issues:
- if we run the mocks in parallel mockgen can try to read the files while they are being rewritten, causing mockgen to fail as it was trying to read the file. We worked around this by targeting directories in parallel but run mockgen sequentially within a directory.
- our IDEs see the files being modified and re-index the codebase over and over, making the IDE mostly unusable while mockgen is running.
Expected behavior If the output file already exist and has the same content mockgen should not rewrite it and leave it untouched.
To Reproduce Steps to reproduce the behavior
Just run mockgen as usual.
Additional Information
- gomock 1.6.0
- golang 1.17.3
Source: golang/mock