Skip to content
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

Add gci to format imports #7347

Closed
sleepymole opened this issue Oct 13, 2022 · 0 comments · Fixed by #7346
Closed

Add gci to format imports #7347

sleepymole opened this issue Oct 13, 2022 · 0 comments · Fixed by #7346
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@sleepymole
Copy link
Contributor

sleepymole commented Oct 13, 2022

Currently, there is no convention on how to group the imports. Different developers may format imports to different groups. This usually results in unnecessary code changes when submitting a PR. Although we use goimports to format the imports, goimports doesn't work correctly in many scenarios, see discussion in golang/go#20818.

gci is a tool that control golang package import order and make it always deterministic. It can always sort imports into exactly two groups or three groups. And gci is also a built-in linter in golangci-lint. So I think we can add gci to our lint scripts. 2 imports groups or 3 import groups is still not yet determined.

There are some known compatibility issues for gci with other linters, see golangci/golangci-lint#1490. But most issues are very rare to encounter.

@sleepymole sleepymole added the type/enhancement The issue or PR belongs to an enhancement. label Oct 13, 2022
ti-chi-bot pushed a commit that referenced this issue Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant