Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Support -local flag for goimports #491

Closed
markwaldkat opened this issue Oct 12, 2020 · 3 comments
Closed

Support -local flag for goimports #491

markwaldkat opened this issue Oct 12, 2020 · 3 comments

Comments

@markwaldkat
Copy link

Dear gomock developers,

we started using a master version of gomock in order to benefit from #458 and stop the "fix goimports" comments on all of our PRs.

The generated mocks have their imports divided in two blocks. However, we want to run goimports in our repository with the -local flag, see https://github.com/golang/tools/blob/master/cmd/goimports/goimports.go#L55, which leads to three blocks imports.

flag.StringVar(&options.LocalPrefix, "local", "", "put imports beginning with this string after 3rd-party packages; comma-separated list")

The issue now, is that if we run goimports with our custom yet common configuration, the mock files are changed.

Would it be possible to forward this flag from outside to the goimports executed after mock generation? It is not possible to exclude files from being changed by goimports, so only a fix here would do the trick.

Cheers,
Mark

PS: Any plans when to cut the 1.5 release?

@cvgw
Copy link
Collaborator

cvgw commented Oct 16, 2020

I think I understand the general issue here; which is how do users pass options to the goimports functionality that gomock executes.... which seems like a massive can of worms 😆

I think this one will need some deliberation and probably successful examples of solving this problem in other tools.

@cvgw
Copy link
Collaborator

cvgw commented Oct 16, 2020

Adding flags for each goimports option we want to expose seems like a bad idea; would be ongoing maintenance toil.

Finding someway to pass the options through without explicit support for each one would probably be an ideal solution.

@codyoss
Copy link
Member

codyoss commented May 14, 2021

At this time we will not allow passing through extra flags for goimports. mockgen already has many flags of its own and we would like to avoid adding more where possible. It is reasonable it you have a different standard for imports that you can adjust the style post generation.

@codyoss codyoss closed this as completed May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants