Skip to content

refactor: modernize interface{} to any and improve eval benchmarks#654

Merged
zhouzhuojie merged 5 commits intomainfrom
modernize-interface-to-any
Feb 6, 2026
Merged

refactor: modernize interface{} to any and improve eval benchmarks#654
zhouzhuojie merged 5 commits intomainfrom
modernize-interface-to-any

Conversation

@zhouzhuojie
Copy link
Collaborator

@zhouzhuojie zhouzhuojie commented Feb 6, 2026

Summary

  • Modernize code to Go 1.18+ style by replacing interface{} with any in config, entity, handler, mapper, and related tests.
  • Keep behavior unchanged for runtime paths while updating type declarations and assertions for consistency.
  • Improve batch evaluation benchmarks to use realistic fixture-backed cache hits instead of mostly not-found lookups.

Commit Breakdown

  • 197a3708 - refactor: modernize interface{} to any for Go 1.18+ compatibility
    • Mechanical interface{} -> any updates across middleware, entity models, handlers, mapper helpers, and tests.
  • efce8334 - Make batch benchmarks use realistic eval cache fixtures
    • Adds a multi-flag benchmark cache fixture and rewires batch benchmarks to use valid IDs/keys/tags.

Benchmark Snapshot

From go test ./pkg/handler -run '^$' -bench 'BenchmarkPostEvaluationBatch$|BenchmarkPostEvaluationBatchWithTags$':

  • BenchmarkPostEvaluationBatch-3: 430084 ns/op
  • BenchmarkPostEvaluationBatchWithTags-3: 229705 ns/op

Validation

  • go test ./... -run '^$'
  • go test ./pkg/handler -run '^$' -bench 'BenchmarkPostEvaluationBatch$|BenchmarkPostEvaluationBatchWithTags$'

zhouzhuojie and others added 2 commits February 6, 2026 20:14
Replace all interface{} type declarations with the modern any keyword
for improved code consistency with Go 1.18+ generics.

Changes:
- pkg/entity/evaluator.go: EvalContext.EntityContext
- pkg/entity/db.go: AutoMigrateTables slice
- pkg/entity/fixture.go: Attachment maps
- pkg/entity/logger.go: variadic logging functions
- pkg/mapper/entity_restapi/r2e/r2e.go: MapAttachment function
- pkg/config/middleware.go: recoveryLogger and JWT validation
- pkg/handler/error.go: Error type and functions
- pkg/handler/eval.go: entity context type assertion
- pkg/handler/subject.go: JWT parsing
- pkg/handler/eval_cache.go: cache functions
- pkg/handler/crud_test.go: test fixtures
- pkg/handler/eval_test.go: test fixtures

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@zhouzhuojie zhouzhuojie changed the title refactor: modernize interface{} to any for Go 1.18+ compatibility refactor: modernize interface{} to any and improve eval benchmarks Feb 6, 2026
@zhouzhuojie zhouzhuojie merged commit 72c8521 into main Feb 6, 2026
9 checks passed
@zhouzhuojie zhouzhuojie deleted the modernize-interface-to-any branch February 6, 2026 21:02
foxdalas pushed a commit to foxdalas/flagr that referenced this pull request Feb 7, 2026
…penflagr#654)

* refactor: modernize interface{} to any for Go 1.18+ compatibility

Replace all interface{} type declarations with the modern any keyword
for improved code consistency with Go 1.18+ generics.

Changes:
- pkg/entity/evaluator.go: EvalContext.EntityContext
- pkg/entity/db.go: AutoMigrateTables slice
- pkg/entity/fixture.go: Attachment maps
- pkg/entity/logger.go: variadic logging functions
- pkg/mapper/entity_restapi/r2e/r2e.go: MapAttachment function
- pkg/config/middleware.go: recoveryLogger and JWT validation
- pkg/handler/error.go: Error type and functions
- pkg/handler/eval.go: entity context type assertion
- pkg/handler/subject.go: JWT parsing
- pkg/handler/eval_cache.go: cache functions
- pkg/handler/crud_test.go: test fixtures
- pkg/handler/eval_test.go: test fixtures

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

* Make batch benchmarks use realistic eval cache fixtures

* Harden CI checks and clean up docs and benchmark fixtures

* update

* update

---------

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
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.

1 participant

Comments