Skip to content

chore: replace interface{} with any and enforce it via lint - #1206

Merged
dangrondahl merged 5 commits into
mainfrom
chore/use-any
Sep 18, 2026
Merged

dangrondahl merged 5 commits into
mainfrom
chore/use-any

Conversation

@dangrondahl

@dangrondahl dangrondahl commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Replaces every interface{} in the codebase with any, and adds a gofmt rewrite rule to .golangci.yml so make lint fails if interface{} is reintroduced.

The main reason is readability. This codebase decodes many API responses into map[string]any and []map[string]any, and those nested types are much easier to scan with the shorter name. any has also been the idiomatic spelling since Go 1.18, and it is what the standard library and go fix use.

any is a pure alias for interface{}, so there is no behaviour change. The large first commit is 558 lines in / 558 lines out: the alias rename plus the struct tag realignment gofmt produces from the shorter name. Reviewing it commit by commit is recommended.

The rename commit also carries one unrelated fix: a comment typo (environemnt) in cmd/kosli/getSnapshot_test.go. That file has no interface{} in it, which is why it otherwise looks out of place.

Follow-up commits from review:

  • make fmt now applies the same rewrite rule, so it can fix what make lint rejects. It uses gofmt -r directly rather than golangci-lint fmt because make build runs in the Dockerfile without golangci-lint.
  • The lint timeout is now set only in .golangci.yml. The --timeout flag was removed from the Makefile and the CI workflow, where it was overriding the config value.

No CLI help text, Helm chart, or Terraform changes are involved.

Checklist

Pure alias rename; any has been the idiomatic spelling since Go 1.18.
The struct tag realignment is gofmt output from the shorter name.
Also sets a 5m run timeout so a hung lint run fails in CI instead of
blocking the job.
@github-actions github-actions Bot added go Pull requests that update go code chore labels Sep 18, 2026
@claude

claude Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @dangrondahl's task in 1m 28s —— View job


Follow-up review complete

  • Fetch previous review comments and identify prior findings
  • Diff 4701306c..99aab78f to see what the new commits changed
  • Assess status of each prior finding
  • Check new commits for bugs/regressions introduced
  • Post summary comment

Prior findings — both resolved and threads closed:

  1. Redundant lint timeout (.golangci.yml:4) — resolved by 44838910 and 99aab78f: --timeout=5m removed from .github/workflows/test.yml and Makefile's lint target; run.timeout: 5m in .golangci.yml is now the single source of truth.
  2. make fmt/make lint gap on the rewrite rule (.golangci.yml:30) — resolved by 99aab78f: fmt target now runs gofmt -l -w -r 'interface{} -> any' $(go list -f '{{.Dir}}' ./...) directly (with a comment explaining why gofmt is used instead of golangci-lint fmt, since golangci-lint isn't available in the Dockerfile build path), matching the rewrite rule enforced by lint.

Verified no interface{} remains anywhere in *.go files, so the new fmt rule and the lint rule are consistent.

New issues in the touched lines: none. The two new commits only touch Makefile and .github/workflows/test.yml; the changes are mechanical (dropping a now-redundant flag, switching go fmt to gofmt with the rewrite rule) and introduce no bugs or regressions.

Comment thread .golangci.yml
Comment thread .golangci.yml
The timeout was passed as a flag in both the Makefile and the CI
workflow, which overrides the config file value.
golangci-lint now rejects interface{} via a gofmt rewrite rule, but
go fmt does not apply rewrite rules, so make fmt could not fix what
make lint rejected. Use gofmt directly rather than golangci-lint fmt
because make build runs in the Dockerfile without golangci-lint.

Also drops the --timeout flag from make lint (see previous commit).
@dangrondahl
dangrondahl enabled auto-merge (squash) September 18, 2026 05:29
@dangrondahl
dangrondahl merged commit 8268d3c into main Sep 18, 2026
23 of 25 checks passed
@dangrondahl
dangrondahl deleted the chore/use-any branch September 18, 2026 06:04
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout=5m -v

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this was removed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional as it's not a part of the PR description?

social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
kosli-cli 2.43.1

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>- Attestation commands now warn (instead of failing) when a CI-defaulted `--commit` cannot be resolved from the repository, allowing jobs without a checked-out repo to proceed without commit info.
- Commands that require commit info (`attest pullrequest`, `attest jira`) now emit a clear error when the commit cannot be resolved, rather than silently proceeding or panicking.
- Explicit `--commit` or `--repo-root` flags that cannot be resolved now produce a descriptive error pointing to the correct fix.

<!-- Release notes generated using configuration in .github/release.yml at v2.43.1 -->

## What's Changed
* fix(k8s): name artifacts by image reference when the runtime reports an image ID by @dangrondahl in kosli-dev/cli#1204
* chore: replace interface{} with any and enforce it via lint by @dangrondahl in kosli-dev/cli#1206
* fix(attest): don't fail when a CI-defaulted --commit has no repository by @mbevc1 in kosli-dev/cli#1202
* fix(table output): sort tags so table output is deterministic by @dangrondahl in kosli-dev/cli#1207


**Full Changelog**: kosli-dev/cli@v2.43.0...v2.43.1

</pre>
  <p>View the full release notes at <a href="https://github.com/kosli-dev/cli/releases/tag/v2.43.1">https://github.com/kosli-dev/cli/releases/tag/v2.43.1</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!20579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore github-actions go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants