-
Notifications
You must be signed in to change notification settings - Fork 3.8k
reformat with goimports -local #7533
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
Conversation
The -local flag allows us to separate imports that originate from github.com/containerd/containerd from other imports, making it more clear where various imports come from. Files can be formatted using the following command: goimports -w -local github.com/containerd/containerd To reformat all Go source files (excluding vendor and .pb.go): goimports -w -local github.com/containerd/containerd \ $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "*.pb.go") Signed-off-by: Samuel Karp <[email protected]>
Signed-off-by: Samuel Karp <[email protected]>
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left comments inline
Some thoughts in general;
- This will be disruptive for some time
- cause quite some merge conflicts on open PRs
- switching between branches (main <--> 1.6 LTS) will require switching tooling settings to use the expected convention
- The linter apparently doesn't do a great job on checking these, and doesn't enforce "3 groups (stdlib, external, local)"
- Perhaps the
gcilinter does handle this? (haven't checked) https://golangci-lint.run/usage/linters/
- Perhaps the
- If we want this format to be enforced, perhaps we need a
make fmttarget, otherwise contributors must typegoimports -w --local github.com/containerd/containerd .(which is a lot to type)
I'm also wondering (if we go ahead with this) would it make sense to change "local" to github.com/containerd/ (all imports from within the containerd org)?
- Packages may move around within the org, and perhaps we want to make that less disruptive
- How should separate modules be treated? e.g. if
github.com/containerd/containerd/apibecomes its own module, is it still "local"? It's in the same repo, but effectively "non-local"
| "sync" | ||
| "time" | ||
|
|
||
| "github.com/sirupsen/logrus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this one needs to be together with the one below
| "k8s.io/klog/v2" | ||
|
|
||
| internalapi "github.com/containerd/containerd/integration/cri-api/pkg/apis" | ||
| runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should go together
| internalapi "github.com/containerd/containerd/integration/cri-api/pkg/apis" | ||
|
|
||
| "github.com/containerd/containerd/integration/remote/util" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should go together
| "k8s.io/klog/v2" | ||
|
|
||
| internalapi "github.com/containerd/containerd/integration/cri-api/pkg/apis" | ||
| "k8s.io/component-base/logs/logreduction" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should to together
| internalapi "github.com/containerd/containerd/integration/cri-api/pkg/apis" | ||
|
|
||
| "github.com/containerd/containerd/integration/remote/util" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should to together
|
|
||
| snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot" | ||
| ctrdutil "github.com/containerd/containerd/pkg/cri/util" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these together with the containerd group above
| "github.com/containerd/containerd/version" | ||
|
|
||
| "github.com/containerd/containerd/pkg/cri/constants" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these together
| "golang.org/x/sys/unix" | ||
|
|
||
| "github.com/containerd/console" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these together
| "github.com/containerd/containerd/pkg/shutdown" | ||
|
|
||
| api "github.com/containerd/containerd/api/runtime/sandbox/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these together
| "github.com/containerd/containerd/services" | ||
|
|
||
| api "github.com/containerd/containerd/api/services/sandbox/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these together
|
Thanks for the thorough review @thaJeztah!
Yep, I want to see what everyone else thinks about this. It'll definitely be disruptive, but I think it makes the imports clearer (and it'll reduce the chance of me/my IDE changing them in other unrelated PRs 😆).
If we're onboard with this change, I think we can do the same thing on the 1.5 and 1.6 branches as well.
My preference would be to do this with
I can do this.
I thought about these too and landed on |
|
This PR is stale because it has been open 90 days with no activity. This PR will be closed in 7 days unless new comments are made or the stale label is removed. |
|
This PR was closed because it has been stalled for 7 days with no activity. |

The -local flag allows us to separate imports that originate from github.com/containerd/containerd from other imports, making it more clear where various imports come from.
Files can be formatted using the following command:
To reformat all Go source files (excluding vendor and .pb.go):