Skip to content

[FEATURE] Enforce Go import order with gci in golangci-lint #222

Description

Summary

Go import grouping is only enforced in inference-gateway/cli, which runs the gci formatter under golangci-lint v2 with a fixed section order (standard, testify, mocks, default, github.com/inference-gateway/, own module). Every other core Go repo lacks that check, so import blocks drift between files and PRs and reviewers end up nitpicking by hand.

Current state in this repo: .golangci.yml exists (v2) and enables gofmt + goimports formatters, but not gci, so there is no enforced grouping between third-party, k8s, github.com/inference-gateway/*, and internal imports. CI runs golangci-lint v2.12.2.

Reference config (.golangci.yml in inference-gateway/cli):

version: "2"

formatters:
  enable:
    - gci
  settings:
    gci:
      custom-order: true
      sections:
        - standard
        - prefix(github.com/stretchr/testify)
        - default
        - prefix(github.com/inference-gateway/)
        - prefix(github.com/inference-gateway/operator)

Adjust the sections to what this repo actually imports (drop testify if unused, add a mocks prefix if there is one). goimports alone is not enough: it only separates stdlib from everything else and does not enforce a stable order for the internal/org groups.

Acceptance Criteria

  • .golangci.yml (v2 schema) enables the gci formatter with custom-order: true and sections matching the CLI layout above, adapted to this module path
  • CI runs golangci-lint run on every PR and fails when imports are not grouped/ordered as configured
  • Existing Go files are reformatted once (golangci-lint fmt) so main is green after the check lands
  • CONTRIBUTING.md / AGENTS.md mentions the import order and how to fix it locally (golangci-lint fmt)

Activity

  1. moved this to Todo in 2026on Sep 16, 2026
  2. moved this from Todo to In progress in 2026on Sep 16, 2026
  3. moved this from In progress to QA in 2026on Sep 16, 2026
  4. moved this from QA to Done in 2026on Sep 16, 2026
  5. inference-gateway-releaser commented on Sep 24, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.25.1 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementreleased

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions