-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group imports as std, external, internal #37
Comments
We already do part of this. We force all standard library imports to be in the first group. I thought about extending the logic to also enforce that the last group contain all the imports from within the same module. However, I think that would be too risky, for two reasons:
|
Makes sense, I didn't think of the complexities of inside/outside modules and forgot about the lack of module-awareness! |
The heuristic here was a bit lax; I've made it a bit more aggressive. See the commit pushed to master just above. |
@mvdan FYI I did notice that there is also https://github.com/daixiang0/gci in this space now |
Thanks! This discussion has now moved to #38 for the most part, which is open. I've left a couple of design proposals near the end of the thread. |
A convention I and coworkers often follow is a further separation of imports by relationship to the current project. So anything from the app/library itself is grouped separately so you can easily see all the external dependencies without them getting mixed with internal dependencies.
It would be neat for gofumpt to read the current package from
go.mod
— which in the example above, would begithub.com/our-company-org/our-project
— then group any package with that prefix at the bottom of the import block.Maybe this is too specific though, I'm not sure if anyone else does this.
The text was updated successfully, but these errors were encountered: