sanposhiho / gomockhandler

Mr. gomockhandler is the clever and more agile manager of golang/mock (uber/mock) 👔
MIT License
105 stars 8 forks source link

Add Configuration File Support for Overriding mockgen_cmd in gomockhandler #91

Closed hori-ryota closed 4 weeks ago

hori-ryota commented 4 weeks ago

When using gomockhandler in a team setting, it is essential to standardize the version of mockgen. Currently, each team member needs to manually align their local version of mockgen.

By allowing the override of mockgen, we can specify the version as follows:

go run go.uber.org/mock/mockgen@v0.4.0

However, specifying the mockgen_cmd through gomockhandler options presents an issue because the go:generate directive does not support options with spaces (quotation will be ignored).

As a temporary workaround, I propose adding a setting to the configuration file that allows the override of the mockgen_cmd. This will enable team-wide consistency without the need for manual version alignment on each developer's machine.

hori-ryota commented 4 weeks ago

If you have any advice on effectively standardizing the mockgen version across a team, it would be greatly appreciated.

sanposhiho commented 4 weeks ago

Actually, not sure we should support it.

If you just want to fix the version, cannot you script -

go install go.uber.org/mock/mockgen@v0.4.0
gomockhandler -config=/path/to/gomockhandler.json mockgen

in your Makefile or whatever?

hori-ryota commented 4 weeks ago

@sanposhiho Thank you for your response!

Using go install sets the version of mockgen globally on the machine. This can lead to conflicts when developing multiple projects on a single machine.

While it's true that running go install for each project during execution can fix the gomock version, it would be preferable to have a solution that is confined to each project and does not interfere with other projects.

sanposhiho commented 4 weeks ago

Using go install sets the version of mockgen globally on the machine.

There are some known tricks for that specific problem. The one I often do is like - https://github.com/mercari/grpc-federation/blob/main/Makefile#L3-L5

hori-ryota commented 4 weeks ago

Certainly, I can overwrite the PATH in the Makefile, so this approach will work! Thank you!

It seems like the issue I'm facing can be resolved with the method you taught me.

sanposhiho commented 4 weeks ago

Cool, let's close the PR then.

/close