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

Why are imports not formatted with goimports? #393

Closed
marten-seemann opened this issue Jan 26, 2020 · 8 comments · Fixed by #458
Closed

Why are imports not formatted with goimports? #393

marten-seemann opened this issue Jan 26, 2020 · 8 comments · Fixed by #458

Comments

@marten-seemann
Copy link
Contributor

I'm wondering why the imports are not formatted according to goimports. When I open a mock file with my editor, it would automatically rearrange the imports, and then I have to revert this change before committing.

Considering that there exists a standard format how to arrange import paths, would it make sense if mockgen already arrange the import statements in that order?

@codyoss
Copy link
Member

codyoss commented Feb 5, 2020

Seems reasonable to me.

@codyoss
Copy link
Member

codyoss commented Feb 28, 2020

@marten-seemann I just took a look quick and it does not appear the goimports has an api we can use unless I missed something in my quick look. To support this we might need to build behavior to mimic how goimports rearranges things. Still a good idea, just had not thought about that initially.

@Willyham
Copy link

I believe that goimports uses this under the hood: https://github.com/golang/tools/blob/a49f79bcc2246daebe8647db377475ffc1523d7b/imports/forward.go#L39 - would that suffice?

@codyoss
Copy link
Member

codyoss commented Mar 25, 2020

I have not tried it out, but that does look promising.

@codyoss
Copy link
Member

codyoss commented Mar 28, 2020

If this does work, I am open to PRs.

@timebertt
Copy link
Contributor

+1 on this
What's the status of this issue?

@codyoss
Copy link
Member

codyoss commented Jul 15, 2020

It is not being actively worked on, but I would be willing to take a PR for the feature.

@timebertt
Copy link
Contributor

Alright.
I just tried it out with @Willyham's suggestion and it seems to be straight-forward.
I will open a PR :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants