Skip to content

[Feature]: Go imports section canonicalization #447

@MikeSpreitzer

Description

@MikeSpreitzer

Feature Area

Other

Problem Statement

There should be something checking that Go imports are in canonical order and grouping. It should be easy for a contributor to put the Go imports in a file into canonical order and grouping.

Canonical grouping is the following groups, in this order.

  1. Imports from Go's stdlib.
  2. Imports of packages that are independent of Kubernetes.
  3. Imports of Kubernetes packages.
  4. Imports of dependencies that depend on Kubernetes.
  5. Imports from other llm-d repos (there are none of these, so far).
  6. Imports of other packages in this repo.

Within each group, imports should be in lexicographic order.

Proposed Solution

CI should include a gating check of this.

We should publish recommendations for how contributors establish, or at least check, compliance before submitting a PR.

Alternatives Considered

No response

Willingness to Contribute

Yes, I can submit a PR

Additional Context

The standard tools gofmt and goimports do ordering within the groups.

goimports -local will handle three groups, not the five that we want.

I usually use VS Code, which is maintaining order within the groups but does not do anything about proper grouping. I find that not terribly difficult to do by hand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions