Skip to content

chore(lint): enforce Go import grouping and named imports - #223

Merged
edenreich merged 3 commits into
mainfrom
fix/issue-222
Sep 16, 2026
Merged

edenreich merged 3 commits into
mainfrom
fix/issue-222

Conversation

@edenreich

@edenreich edenreich commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #222

Summary

Enables the gci formatter with the shared section order from inference-gateway/cli, adapted to this module, plus importas so every non-standard-library import is explicitly named (same approach as inference-gateway/inference-gateway#667, inference-gateway/sdk#182, inference-gateway/adk#307). Existing files were reformatted once so main is green after the check lands.

Changes

  • .golangci.yml: enable gci with custom-order: true and sections standard, prefix(github.com/onsi) (ginkgo/gomega), default, prefix(github.com/inference-gateway/), prefix(github.com/inference-gateway/operator)
  • .golangci.yml: enable importas with no-unaliased: true. Two regex rules keep the kubebuilder convention for versioned API packages (k8s.io/api/core/v1 → corev1, apimachinery/pkg/apis/meta/v1 → metav1); a catch-all derives every other alias from the last path element. Six conventional aliases are pinned because the derived name collides or is meaningless: ctrl, apierrors, utilruntime, clientgoscheme, gwapiv1, corev1alpha1
  • Reformat existing files with golangci-lint fmt / golangci-lint run --fix; the inconsistent apiErrors alias is unified to apierrors. Generated files (zz_generated*) stay untouched via generated: lax
  • cmd/main.go: the two-line comment above the blank client-go/plugin/pkg/client/auth import became a trailing comment; gci and goimports disagree on where a comment-attached import sorts
  • Document the import order, the naming rule, and the local fix commands in AGENTS.md and CONTRIBUTING.md

Verification

  • task generate, task manifests and task generate:providers re-run: no drift in zz_generated* or config/
  • task test (envtest) passes
  • golangci-lint run reports only the pre-existing staticcheck finding on main (ctrl.Result{Requeue: true} is deprecated), unrelated to this change

Notes

CI already runs task lint on every PR, so both checks are enforced with no workflow change.

Enable the gci formatter in .golangci.yml with the shared section order
adapted to this module: standard, github.com/onsi (ginkgo/gomega),
third-party, github.com/inference-gateway/, then this module. Existing
files were reformatted once; the multi-line comment above the blank
client-auth import in cmd/main.go became a trailing comment because gci
and goimports disagree on where comment-attached imports sort.
@edenreich
edenreich requested a review from a team as a code owner September 16, 2026 14:32
Comment thread cmd/main.go Resolved
@edenreich edenreich changed the title chore(lint): enforce Go import grouping and ordering with gci chore(lint): enforce Go import grouping and named imports Sep 16, 2026
Enable importas so every non-standard-library import is named. Two
regex rules keep the kubebuilder convention for versioned k8s API
packages (corev1, appsv1, metav1); a catch-all derives every other alias
from the last path element. The conventional ctrl, apierrors,
utilruntime, clientgoscheme, gwapiv1 and corev1alpha1 aliases are pinned
because the derived names collide or are meaningless (runtime, errors,
apis). The inconsistent apiErrors alias is unified to apierrors.
controller-gen and the providers generator were re-run: no drift.
@edenreich
edenreich merged commit 7ae0d6d into main Sep 16, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-222 branch September 16, 2026 14:57
inference-gateway-releaser Bot added a commit that referenced this pull request Sep 24, 2026
## [0.25.1](v0.25.0...v0.25.1) (2026-09-24)

### ♻️ Improvements

* **gateway:** render MCP_SERVERS as name=url aliases ([#236](#236)) ([3bfb7ac](3bfb7ac))

### 👷 CI

* **claude:** centralize claude.yml via reusable workflow ([#232](#232)) ([4d2a583](4d2a583))
* **deps:** bump github.com/onsi/ginkgo/v2 in the gomod group ([#218](#218)) ([5eb52ff](5eb52ff))
* **deps:** bump go.opentelemetry.io/otel/exporters/otlp/otlptrace ([#225](#225)) ([e681bae](e681bae))
* **deps:** bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc ([#227](#227)) ([5674492](5674492))
* **deps:** bump rancher/k3s from v1.36.4-k3s1 to v1.37.0-k3s1 in the docker group ([#228](#228)) ([343e738](343e738))
* **deps:** bump rancher/k3s in the docker group ([#219](#219)) ([50089f7](50089f7))
* **deps:** bump the gomod group with 3 updates ([#229](#229)) ([e016a01](e016a01))

### 📚 Documentation

* Document pre-commit hook and coverage command in AGENTS.md ([#224](#224)) ([aebbec0](aebbec0))

### 🔧 Miscellaneous

* **deps:** bump claude-code 2.1.245 -> 2.1.266 ([#220](#220)) ([09b15b8](09b15b8))
* **deps:** bump claude-code 2.1.266 -> 2.1.278 ([#230](#230)) ([114a61e](114a61e))
* **deps:** bump infer CLI v0.183.0 -> v0.192.0 ([#221](#221)) ([5186c52](5186c52))
* **deps:** bump infer CLI v0.192.0 -> v0.205.3 ([#231](#231)) ([099c939](099c939))
* **lint:** enforce Go import grouping and named imports ([#223](#223)) ([7ae0d6d](7ae0d6d))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.25.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant