Skip to content

Fix goconst lint errors after golangci-lint v2.12 update#97

Merged
rdimitrov merged 1 commit intomainfrom
fix/goconst-lint-errors
May 5, 2026
Merged

Fix goconst lint errors after golangci-lint v2.12 update#97
rdimitrov merged 1 commit intomainfrom
fix/goconst-lint-errors

Conversation

@jhrozek
Copy link
Copy Markdown
Contributor

@jhrozek jhrozek commented May 5, 2026

Summary

  • The latest golangci-lint (v2.12.x) detects more repeated string literals in the goconst linter, surfacing 95 new issues across the codebase. This was visible on PR Update module github.com/mark3labs/mcp-go to v0.51.0 #96 (a Renovate dependency bump) where lint failed despite no code changes from the PR.
  • Extract repeated literals into named constants — production code uses package-level constants (some exported where semantically meaningful, e.g. MediaTypeOCIEmptyV1JSON, ArchAMD64, SkillFileName), test files use unexported package-level test constants.
  • No behavior changes. task lint is clean and the full test suite passes.

Affected packages

Package Issues fixed Notes
cel 10 Test-only constants for CEL expressions and claim names
container/verifier 5 Hoisted OCI/Sigstore media types into utils.go
oci/skills 23 Exported OSLinux, ArchAMD64, ArchARM64, SkillFileName; added testconsts_test.go
permissions 13 Test-only constants for paths and mount declarations
registry/converters 34 Production constants in toolhive_to_upstream.go; added testconst_test.go
registry/types 9 Added test_constants_test.go
validation/http 1 Single test-case-name constant

Test plan

  • task lint passes with 0 issues
  • task test passes (all packages green)
  • task license-check passes for the new files
  • No public API changes that would break downstream consumers

🤖 Generated with Claude Code

The latest golangci-lint (v2.12.x) detects more repeated string literals
in the goconst linter, surfacing 95 issues across the codebase that were
previously not flagged. Extract repeated literals into named constants:

- Production code (`oci/skills`, `container/verifier`,
  `registry/converters`): hoist shared OCI media types, architecture
  names, default version/status, and the SKILL.md filename into
  package-level constants. A few are exported where they have semantic
  meaning to callers (e.g. MediaTypeOCIEmptyV1JSON, ArchAMD64,
  SkillFileName).
- Test files (`cel`, `permissions`, `registry/types`,
  `registry/converters`, `oci/skills`, `validation/http`): introduce
  unexported package-level test constants for repeated literals
  (test-case names, fixture values, expected error substrings,
  fixture paths). Where it kept things tidy, constants live in a
  dedicated `*_test.go` file shared across the package.

No behavior changes — `task lint` reports 0 issues and the full test
suite passes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jhrozek jhrozek force-pushed the fix/goconst-lint-errors branch from 9566497 to 0aec520 Compare May 5, 2026 08:56
@rdimitrov rdimitrov merged commit 9eafa91 into main May 5, 2026
5 checks passed
@rdimitrov rdimitrov deleted the fix/goconst-lint-errors branch May 5, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants