build
build copied to clipboard
[FEATURE] Revisit Go imports
Is there an existing feature request for this?
- [X] I have searched the existing feature requests
Is your feature request related to a problem or use-case? Please describe.
The imports we go in our Go sources are not consistent and not ideal for code reviews.
In particular, when reviewing a PR like this, it would be helpful if import changes come without alias changes.
Describe the solution that you would like.
In the community meeting, we concluded that we will use names like buildapi or pipelineapi going forward for API imports to make them independent of the imported version. Exceptions would still be allowed when we import more than one version (like we do in triggers for Tekton as we need v1 to work with Pipelines but also v1beta1 for Runs).
In addition, Matthias suggested to evaluate if a tool exists that verifies that imports are as expected, and can maybe autofix this.
Describe alternatives you have considered.
No response
Anything else?
No response
We can consider to use goimports if its features would be helpful for our ideas. Need to verify the feature set first.
We can consider to use
goimportsif its features would be helpful for our ideas. Need to verify the feature set first.
Checked the tool. It can do things like reordering imports but I found no way to rename imports in the way we want it.
From refinement - adding to backlog as having a community standard on import ordering would be beneficial.
Enforcing a standard on import namings is a lot more challenging - per @SaschaSchwarze0 no tooling exists yet to enforce a pattern. goimports can at least enforce standards on import ordering, and we can enable it with golangci-lint.