-
Notifications
You must be signed in to change notification settings - Fork 1.2k
✨ [golangci-lint] add local-prefixes to linters-settings of goimports #3109
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
✨ [golangci-lint] add local-prefixes to linters-settings of goimports #3109
Conversation
Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
|
LGTM label has been added. Git tree hash: ac5e7c13cd537b1f5dc59a9863c390ca07773262
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: schrej, tariq1890 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Why? |
|
I've updated the PR description |
|
Can you please link the Go conventions you are referring to? |
To quote the google style guide you are linking
(So sounds like 3 groups would be "acceptable" for Google, but the "should" mentions 2 groups) That the goimports binary supports to have local imports doesn't seem to indicate a strong perference towards having 3 groups. |
|
Why do we have three groups on cluster-api? |
Very good question. I think because at some point someone had an opinion about it (likely me 😂). But not necessarily because it's an established convention in Go. |
|
So I took a look out of curiosity and you were the one that enabled
While it's not super important to have, I agree with it being easier to differentiate. Internally we're usually even splitting into four groups: std library, external, internal and module. |
|
Thx for looking it up. I was mostly curious if there are actually Go conventions about this somewhere :) I was preferring the split in 3 groups a while back, but over the years I realized that it makes absolutely 0 difference for me. I'm simply never manually reading over the imports in a way that the grouping would help. That being said, just my personal opinion. No strong opinion either way In general I have a preference for trying to not enforce personal preferences in Open Source projects, if it doesn't matter much either way. @vincepri @alvaroaleman WDYT? |
|
I don't really care much either way, I like to have stdlib in its own group but thats it |
I disagree with the characterisation that this is a "personal preference". This has been a common practice in Go for several years, it is exemplified by the fact |
|
Golangci-lint has a huge number of fields that allow all sorts of linter configurations. That doesn't make every one of them a best practice. The fact that this is configurable and not the default in goimports makes it pretty clear to me that there is no clear consensus that this is the one standard for how to format imports. I'm not saying that you are the only one who prefers this. I'm just saying there is no clear standard that everyone should or has to do it this way. Which makes it a personal preference for me See also #3109 (comment) Apparently nobody can point to a well known style guide that says folks should use 3 groups |
This PR adds a check to ensure that all first-party/local imports are moved to their own imports section
Sorting imports into groups helps with code readability. As per Go conventions, we maintain the following import groups: