Skip to content

🧹 chore: remove unneeded "utils" alias#3834

Merged
ReneWerner87 merged 3 commits intogofiber:mainfrom
arturmelanchyk:cleanup
Nov 3, 2025
Merged

🧹 chore: remove unneeded "utils" alias#3834
ReneWerner87 merged 3 commits intogofiber:mainfrom
arturmelanchyk:cleanup

Conversation

@arturmelanchyk
Copy link
Contributor

@arturmelanchyk arturmelanchyk commented Nov 2, 2025

Description

This PR is simply cleaning the code, mostly removes unneeded utils alias

Changes introduced

List the new features or adjustments introduced in this pull request. Provide details on benchmarks, documentation updates, changelog entries, and if applicable, the migration guide.

  • Benchmarks: Describe any performance benchmarks and improvements related to the changes.
  • Documentation Update: Detail the updates made to the documentation and links to the changed files.
  • Changelog/What's New: Include a summary of the additions for the upcoming release notes.
  • Migration Guide: If necessary, provide a guide or steps for users to migrate their existing code to accommodate these changes.
  • API Alignment with Express: Explain how the changes align with the Express API.
  • API Longevity: Discuss the steps taken to ensure that the new or updated APIs are consistent and not prone to breaking changes.
  • Examples: Provide examples demonstrating the new features or changes in action.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Enhancement (improvement to existing features and functionality)
  • Documentation update (changes to documentation)
  • Performance improvement (non-breaking change which improves efficiency)
  • Code consistency (non-breaking change which improves code reliability and robustness)

Checklist

Before you submit your pull request, please make sure you meet these requirements:

  • Followed the inspiration of the Express.js framework for new functionalities, making them similar in usage.
  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Updated the documentation in the /docs/ directory for Fiber's documentation.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Verified that any new dependencies are essential and have been agreed upon by the maintainers/community.
  • Aimed for optimal performance with minimal allocations in the new code.
  • Provided benchmarks for the new code to analyze and improve upon.

Commit formatting

Please use emojis in commit messages for an easy way to identify the purpose or intention of a commit. Check out the emoji cheatsheet here: CONTRIBUTING.md

Signed-off-by: Artur Melanchyk <13834276+arturmelanchyk@users.noreply.github.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 2, 2025

Walkthrough

Standardizes imports by removing explicit utils aliases for github.com/gofiber/utils/v2 across the codebase; includes a small type-assertion formatting change and a type refinement in request range construction; additionally refactors in-memory storage Entry exposure and context error wrapping, and hardens TLS test config generation/signatures.

Changes

Cohort / File(s) Change Summary
Top-level & core files
app.go, app_test.go, bind.go, ctx.go, ctx_test.go, mount.go, path.go, redirect.go, router.go, router_test.go, res.go
Removed explicit import alias utils "github.com/gofiber/utils/v2" in favor of direct import; no logic changes.
Request / Response
req.go, listen_test.go
Removed import alias; in req.go replaced anonymous Range struct with concrete RangeSet when appending to DefaultReq.Range.
Binder package
binder/...
binder/cbor.go, binder/cookie.go, binder/form.go, binder/header.go, binder/json.go, binder/mapping.go, binder/msgpack.go, binder/resp_header.go, binder/xml.go
Removed import alias; files continue to reference package via its default name.
Client package
client/client.go, client/client_test.go, client/cookiejar.go, client/hooks.go, client/request.go, client/response.go
Removed import alias; no behavior changes.
Middleware
middleware/...
adaptor/adaptor.go, basicauth/basicauth.go, cache/*, cors/cors.go, csrf/*, idempotency/idempotency.go, keyauth/keyauth.go, limiter/*, logger/*, pprof/pprof.go, proxy/proxy.go, requestid/config.go, session/*, static/static.go
Removed import alias across middleware modules; no control-flow or semantic changes.
Helpers & extractors
helpers.go, helpers_test.go, extractors/extractors.go
Removed import alias; usages remain with package default name.
Logging
log/default.go
Removed import alias; no behavior change.
Internal memory & storage
internal/memory/memory.go, internal/memory/memory_test.go, internal/storage/memory/memory.go, internal/storage/memory/memory_test.go
Removed import alias in memory files; in internal/storage/memory/memory.go introduced exported Entry type (replacing internal entry), changed Conn() to return map[string]Entry, refactored context-cancellation handling to use wrapContextError(ctx, op) helper; tests updated to use require.Empty in places.
TLS test utilities
internal/tlstest/tls.go
Signature changed: now returns (*tls.Config, *tls.Config, error); added explicit error wrapping, PEM encoding/append cert checks, set MinVersion TLS1.2, and overall stronger error handling.
Type assertion cosmetic
register.go
Simplified compile-time assertion from var _ (Register) = (*Registering)(nil) to var _ Register = (*Registering)(nil).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant Storage
  participant Context

  Note over Caller,Storage: GetWithContext / SetWithContext / DeleteWithContext flow (refactored)
  Caller->>Storage: Call GetWithContext(key, ctx)
  Storage->>Context: check ctx.Done() via wrapContextError(ctx, "Get")
  alt ctx done
    Context-->>Storage: context error
    Storage-->>Caller: return wrapContextError result (operation-specific error)
  else not done
    Storage-->>Storage: perform map lookup using map[string]Entry
    Storage-->>Caller: return value / nil
  end
Loading
sequenceDiagram
  autonumber
  participant TestRunner
  participant TLSUtil

  Note over TestRunner,TLSUtil: GetTLSConfigs() new flow with explicit error checks
  TestRunner->>TLSUtil: GetTLSConfigs()
  TLSUtil->>TLSUtil: generate CA key & cert (check errors)
  TLSUtil->>TLSUtil: encode PEM (check errors)
  TLSUtil->>TLSUtil: generate server key & cert (check errors)
  TLSUtil->>TLSUtil: create tls.Config(s), set MinVersion=TLS1.2
  TLSUtil->>TLSUtil: append CA to client RootCAs (check success)
  TLSUtil-->>TestRunner: return serverConfig, clientConfig, nil or wrapped error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas requiring extra attention:
    • internal/storage/memory/memory.go: exported Entry type, Conn() signature change, and wrapContextError semantics.
    • internal/tlstest/tls.go: API signature change and tightened error handling—verify callers/tests updated accordingly.
    • req.go: Range element type change—ensure consumers still compile.
    • Spot-check files where AI summaries flagged potential compile issues (e.g., binder/json.go, binder/header.go) to confirm default package name is utils.

Possibly related PRs

Suggested reviewers

  • sixcolors
  • ReneWerner87
  • efectn

Poem

🐰 I hopped through imports, tidy and spry,
Dropped extra aliases, waved them goodbye.
Entries exposed, TLS made more tight,
Clean code, small changes—oh what delight! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description is largely incomplete when compared against the provided template structure. The author supplied only a single sentence of substantive content ("This PR is simply cleaning the code, mostly removes unneeded utils alias") followed by a series of empty template placeholders. The "Changes introduced" section lists all template items completely unchecked with no details provided. Critical sections such as detailed change description, issues resolved, benefits to the project, and most checklist items are either missing or left as unchecked boxes. While the core purpose and change type (Code consistency) are identified, the description lacks the supporting details expected by the template, making it significantly incomplete.
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "🧹 chore: remove unneeded 'utils' alias" accurately reflects the primary objective of the changeset. The raw summary shows that the vast majority of changes across 40+ files involve removing import aliases for the gofiber utils package, replacing explicit aliases like utils "github.com/gofiber/utils/v2" with plain imports. While there are some secondary changes (Entry type exposure in memory.go, GetTLSConfigs refactoring in tlstest/tls.go, and test assertion style updates), the dominant theme of the PR is clearly captured by the title. The title is concise, specific, and clearly communicates the main purpose to someone scanning the pull request history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8af7f01 and 3ebe3dc.

⛔ Files ignored due to path filters (1)
  • .golangci.yml is excluded by !**/*.yml
📒 Files selected for processing (3)
  • internal/storage/memory/memory.go (9 hunks)
  • internal/storage/memory/memory_test.go (5 hunks)
  • internal/tlstest/tls.go (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Apply formatting using gofumpt (Make target: format)
Optimize struct field alignment using betteralign (Make target: betteralign)
Modernize code using gopls modernize (Make target: modernize)

Files:

  • internal/tlstest/tls.go
  • internal/storage/memory/memory_test.go
  • internal/storage/memory/memory.go
🧠 Learnings (7)
📓 Common learnings
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
📚 Learning: 2024-12-13T08:14:22.851Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the `require` methods from the `testify` package for assertions instead of manual comparisons and calls to `t.Fatal` or `t.Fatalf`.

Applied to files:

  • internal/storage/memory/memory_test.go
📚 Learning: 2024-07-26T21:00:12.902Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The project uses the testify/assert package for assertions in unit tests.

Applied to files:

  • internal/storage/memory/memory_test.go
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • internal/storage/memory/memory_test.go
📚 Learning: 2024-10-02T23:03:31.727Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-02T23:03:31.727Z
Learning: Unit tests in this project use testify require.

Applied to files:

  • internal/storage/memory/memory_test.go
📚 Learning: 2025-10-22T13:48:12.485Z
Learnt from: CR
Repo: gofiber/fiber PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-22T13:48:12.485Z
Learning: Run golangci-lint (Make target: lint)

Applied to files:

  • internal/storage/memory/memory.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:16-26
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the session middleware `Config` struct, `Store` is backed by `fiber.Storage`; they are different entities serving distinct purposes in session management.

Applied to files:

  • internal/storage/memory/memory.go
🧬 Code graph analysis (1)
internal/storage/memory/memory.go (1)
storage_interface.go (1)
  • Storage (10-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: lint
  • GitHub Check: Compare
  • GitHub Check: unit (1.25.x, windows-latest)
  • GitHub Check: unit (1.25.x, macos-13)
  • GitHub Check: repeated
🔇 Additional comments (4)
internal/storage/memory/memory.go (3)

23-28: LGTM! Entry struct appropriately exported for internal testing.

The struct is now exported to support the Conn() method (line 195), which returns the underlying map for testing purposes. Since this is in an internal/ package, the export doesn't affect the public API. The struct fields remain unexported, maintaining proper encapsulation.


227-232: Excellent refactor! Centralizes context error handling.

The wrapContextError helper provides clean, consistent error wrapping across all *WithContext methods. The use of fmt.Errorf with %w properly preserves the error chain for errors.Is checks.


69-71: Clean refactor! Context error handling now consistent across all methods.

The refactored *WithContext methods now use the wrapContextError helper, eliminating code duplication and providing consistent error messages. The early return pattern is clear and idiomatic.

Also applies to: 102-104, 123-125, 141-143

internal/storage/memory/memory_test.go (1)

127-127: Good improvement! More semantic assertion for empty slices.

The change from require.Zero to require.Empty is more idiomatic for checking empty byte slices. While both would pass, require.Empty better expresses the intent of verifying that no data is returned.

Also applies to: 159-159, 171-171, 198-198, 251-251, 255-255


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@arturmelanchyk arturmelanchyk changed the title chore: cleanup code chore: remove unneeded utils alias Nov 2, 2025
@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.19%. Comparing base (7a17195) to head (3ebe3dc).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3834      +/-   ##
==========================================
- Coverage   92.26%   92.19%   -0.07%     
==========================================
  Files         115      115              
  Lines        9745     9742       -3     
==========================================
- Hits         8991     8982       -9     
- Misses        480      485       +5     
- Partials      274      275       +1     
Flag Coverage Δ
unittests 92.19% <100.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@arturmelanchyk arturmelanchyk changed the title chore: remove unneeded utils alias 🧹 chore: remove unneeded utils alias Nov 2, 2025
@arturmelanchyk arturmelanchyk changed the title 🧹 chore: remove unneeded utils alias 🧹 chore: remove unneeded "utils" alias Nov 2, 2025
@arturmelanchyk arturmelanchyk marked this pull request as ready for review November 2, 2025 11:09
@arturmelanchyk arturmelanchyk requested a review from a team as a code owner November 2, 2025 11:09
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
internal/memory/memory.go (1)

9-9: Memory store: import cleanup — OK; minor ergonomics note

LGTM. Since New() calls utils.StartTimeStampUpdater(), ensure it’s globally idempotent to avoid redundant goroutines when multiple stores are created; otherwise centralize call at app bootstrap.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11be17d and 8af7f01.

📒 Files selected for processing (60)
  • app.go (1 hunks)
  • app_test.go (1 hunks)
  • bind.go (1 hunks)
  • binder/cbor.go (1 hunks)
  • binder/cookie.go (1 hunks)
  • binder/form.go (1 hunks)
  • binder/header.go (1 hunks)
  • binder/json.go (1 hunks)
  • binder/mapping.go (1 hunks)
  • binder/msgpack.go (1 hunks)
  • binder/resp_header.go (1 hunks)
  • binder/xml.go (1 hunks)
  • client/client.go (1 hunks)
  • client/client_test.go (1 hunks)
  • client/cookiejar.go (1 hunks)
  • client/hooks.go (1 hunks)
  • client/request.go (1 hunks)
  • client/response.go (1 hunks)
  • ctx.go (1 hunks)
  • ctx_test.go (1 hunks)
  • extractors/extractors.go (1 hunks)
  • helpers.go (1 hunks)
  • helpers_test.go (1 hunks)
  • internal/memory/memory.go (1 hunks)
  • internal/memory/memory_test.go (1 hunks)
  • internal/storage/memory/memory.go (3 hunks)
  • listen_test.go (1 hunks)
  • log/default.go (1 hunks)
  • middleware/adaptor/adaptor.go (1 hunks)
  • middleware/basicauth/basicauth.go (1 hunks)
  • middleware/cache/cache.go (1 hunks)
  • middleware/cache/cache_test.go (1 hunks)
  • middleware/cache/config.go (1 hunks)
  • middleware/cache/manager_test.go (1 hunks)
  • middleware/cors/cors.go (1 hunks)
  • middleware/csrf/config.go (1 hunks)
  • middleware/csrf/csrf.go (1 hunks)
  • middleware/csrf/csrf_test.go (1 hunks)
  • middleware/csrf/storage_manager.go (1 hunks)
  • middleware/idempotency/idempotency.go (1 hunks)
  • middleware/keyauth/keyauth.go (1 hunks)
  • middleware/limiter/limiter_fixed.go (1 hunks)
  • middleware/limiter/limiter_sliding.go (1 hunks)
  • middleware/logger/default_logger.go (1 hunks)
  • middleware/logger/template_chain.go (1 hunks)
  • middleware/logger/utils.go (1 hunks)
  • middleware/pprof/pprof.go (1 hunks)
  • middleware/proxy/proxy.go (1 hunks)
  • middleware/requestid/config.go (1 hunks)
  • middleware/session/config.go (1 hunks)
  • middleware/session/session.go (1 hunks)
  • middleware/static/static.go (1 hunks)
  • mount.go (1 hunks)
  • path.go (1 hunks)
  • redirect.go (1 hunks)
  • register.go (1 hunks)
  • req.go (2 hunks)
  • res.go (1 hunks)
  • router.go (1 hunks)
  • router_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Apply formatting using gofumpt (Make target: format)
Optimize struct field alignment using betteralign (Make target: betteralign)
Modernize code using gopls modernize (Make target: modernize)

Files:

  • ctx.go
  • router_test.go
  • app.go
  • binder/header.go
  • req.go
  • middleware/keyauth/keyauth.go
  • extractors/extractors.go
  • listen_test.go
  • binder/xml.go
  • binder/mapping.go
  • ctx_test.go
  • middleware/limiter/limiter_sliding.go
  • middleware/csrf/csrf_test.go
  • mount.go
  • middleware/basicauth/basicauth.go
  • middleware/csrf/csrf.go
  • middleware/pprof/pprof.go
  • client/request.go
  • internal/memory/memory.go
  • client/client_test.go
  • app_test.go
  • res.go
  • log/default.go
  • middleware/cache/manager_test.go
  • middleware/cache/cache.go
  • middleware/limiter/limiter_fixed.go
  • middleware/cors/cors.go
  • binder/cookie.go
  • middleware/logger/utils.go
  • middleware/cache/cache_test.go
  • router.go
  • redirect.go
  • client/cookiejar.go
  • helpers.go
  • binder/form.go
  • middleware/logger/template_chain.go
  • middleware/logger/default_logger.go
  • binder/msgpack.go
  • path.go
  • middleware/static/static.go
  • client/client.go
  • middleware/requestid/config.go
  • binder/resp_header.go
  • bind.go
  • middleware/proxy/proxy.go
  • internal/memory/memory_test.go
  • client/response.go
  • middleware/csrf/config.go
  • middleware/idempotency/idempotency.go
  • middleware/session/session.go
  • binder/json.go
  • register.go
  • middleware/adaptor/adaptor.go
  • middleware/csrf/storage_manager.go
  • middleware/session/config.go
  • middleware/cache/config.go
  • helpers_test.go
  • client/hooks.go
  • internal/storage/memory/memory.go
  • binder/cbor.go
🧠 Learnings (14)
📚 Learning: 2025-09-28T17:39:26.644Z
Learnt from: arturmelanchyk
Repo: gofiber/fiber PR: 3768
File: client/request.go:162-166
Timestamp: 2025-09-28T17:39:26.644Z
Learning: In fasthttp-based code like gofiber, using utils.UnsafeString(key) instead of string(key) is acceptable when values are used immediately within the same call stack and not stored for later use, as it avoids allocations and aligns with fasthttp's zero-allocation design philosophy.

Applied to files:

  • ctx.go
  • router_test.go
  • app.go
  • binder/header.go
  • req.go
  • middleware/keyauth/keyauth.go
  • listen_test.go
  • binder/mapping.go
  • middleware/basicauth/basicauth.go
  • middleware/pprof/pprof.go
  • client/request.go
  • app_test.go
  • res.go
  • log/default.go
  • middleware/cache/cache.go
  • middleware/cors/cors.go
  • binder/cookie.go
  • middleware/cache/cache_test.go
  • router.go
  • redirect.go
  • client/cookiejar.go
  • helpers.go
  • middleware/logger/default_logger.go
  • path.go
  • middleware/static/static.go
  • client/client.go
  • binder/resp_header.go
  • middleware/proxy/proxy.go
  • client/response.go
  • middleware/idempotency/idempotency.go
  • middleware/session/session.go
  • middleware/adaptor/adaptor.go
  • helpers_test.go
  • client/hooks.go
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • ctx.go
  • router_test.go
  • app.go
  • binder/header.go
  • req.go
  • listen_test.go
  • ctx_test.go
  • middleware/csrf/csrf_test.go
  • middleware/csrf/csrf.go
  • middleware/pprof/pprof.go
  • client/request.go
  • client/client_test.go
  • app_test.go
  • res.go
  • middleware/cache/manager_test.go
  • middleware/cache/cache.go
  • middleware/cors/cors.go
  • binder/cookie.go
  • middleware/cache/cache_test.go
  • router.go
  • client/cookiejar.go
  • helpers.go
  • middleware/logger/default_logger.go
  • middleware/static/static.go
  • client/client.go
  • binder/resp_header.go
  • middleware/proxy/proxy.go
  • internal/memory/memory_test.go
  • client/response.go
  • middleware/session/session.go
  • middleware/adaptor/adaptor.go
  • helpers_test.go
  • client/hooks.go
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • router_test.go
  • app.go
  • listen_test.go
  • ctx_test.go
  • middleware/csrf/csrf_test.go
  • mount.go
  • middleware/csrf/csrf.go
  • client/client_test.go
  • app_test.go
  • router.go
  • redirect.go
  • binder/form.go
  • path.go
  • bind.go
  • middleware/proxy/proxy.go
  • middleware/idempotency/idempotency.go
  • middleware/adaptor/adaptor.go
  • helpers_test.go
📚 Learning: 2024-07-26T21:00:12.902Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The project uses the testify/assert package for assertions in unit tests.

Applied to files:

  • router_test.go
  • listen_test.go
  • ctx_test.go
  • middleware/csrf/csrf_test.go
  • client/client_test.go
  • app_test.go
  • res.go
  • middleware/cache/manager_test.go
  • middleware/cache/cache_test.go
  • internal/memory/memory_test.go
  • helpers_test.go
📚 Learning: 2024-10-02T23:03:31.727Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-02T23:03:31.727Z
Learning: Unit tests in this project use testify require.

Applied to files:

  • router_test.go
  • listen_test.go
  • ctx_test.go
  • middleware/csrf/csrf_test.go
  • client/client_test.go
  • app_test.go
  • middleware/cache/manager_test.go
  • middleware/cache/cache_test.go
  • internal/memory/memory_test.go
  • helpers_test.go
📚 Learning: 2024-12-13T08:14:22.851Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the `require` methods from the `testify` package for assertions instead of manual comparisons and calls to `t.Fatal` or `t.Fatalf`.

Applied to files:

  • router_test.go
  • listen_test.go
  • client/client_test.go
  • app_test.go
  • middleware/cache/manager_test.go
  • internal/memory/memory_test.go
  • helpers_test.go
📚 Learning: 2025-10-16T07:15:26.529Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:15:26.529Z
Learning: In Fiber v3, net/http handlers (http.Handler, http.HandlerFunc, or raw func(http.ResponseWriter, *http.Request)) can be passed directly to routing methods like app.Get(), app.Post(), etc. The framework automatically detects and wraps them internally via toFiberHandler/collectHandlers. The github.com/gofiber/fiber/v3/middleware/adaptor package is legacy and should not be suggested for tests or code using native net/http handler support.

Applied to files:

  • app.go
  • binder/header.go
  • middleware/csrf/csrf_test.go
  • middleware/pprof/pprof.go
  • client/request.go
  • middleware/cache/cache.go
  • binder/cookie.go
  • middleware/cache/cache_test.go
  • middleware/static/static.go
  • client/client.go
  • middleware/requestid/config.go
  • binder/resp_header.go
  • middleware/proxy/proxy.go
  • middleware/session/session.go
  • middleware/adaptor/adaptor.go
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.

Applied to files:

  • app.go
  • binder/header.go
  • middleware/keyauth/keyauth.go
  • middleware/pprof/pprof.go
  • client/request.go
  • middleware/cache/cache.go
  • binder/cookie.go
  • middleware/static/static.go
  • client/client.go
  • binder/resp_header.go
  • middleware/proxy/proxy.go
  • middleware/adaptor/adaptor.go
📚 Learning: 2024-11-08T04:10:42.990Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.

Applied to files:

  • middleware/keyauth/keyauth.go
  • ctx_test.go
  • client/request.go
  • path.go
  • middleware/proxy/proxy.go
📚 Learning: 2024-10-12T10:01:44.206Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/middleware_test.go:190-191
Timestamp: 2024-10-12T10:01:44.206Z
Learning: When testing session `IdleTimeout` expiration, it's acceptable to use `time.Sleep` to simulate the passage of time in tests.

Applied to files:

  • listen_test.go
  • app_test.go
  • middleware/cache/manager_test.go
  • internal/memory/memory_test.go
  • helpers_test.go
📚 Learning: 2024-11-29T12:37:27.581Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: app_test.go:893-895
Timestamp: 2024-11-29T12:37:27.581Z
Learning: In the `Test_App_ShutdownWithContext` function in `app_test.go`, the `clientDone` channel is used to synchronize the client's request completion before proceeding, eliminating the need for additional `time.Sleep` calls.

Applied to files:

  • listen_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:16-26
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the session middleware `Config` struct, `Store` is backed by `fiber.Storage`; they are different entities serving distinct purposes in session management.

Applied to files:

  • internal/memory/memory.go
  • middleware/requestid/config.go
  • middleware/session/config.go
  • middleware/cache/config.go
  • internal/storage/memory/memory.go
📚 Learning: 2025-07-27T17:28:53.403Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3625
File: middleware/session/config.go:57-58
Timestamp: 2025-07-27T17:28:53.403Z
Learning: In the session middleware `Config` struct, the `Extractor` field uses function closures (like `FromCookie(key)`), making it impossible to introspect extractor parameters at runtime for validation purposes without complex reflection techniques.

Applied to files:

  • middleware/csrf/config.go
  • middleware/session/config.go
📚 Learning: 2024-10-02T15:16:39.868Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/session.go:272-293
Timestamp: 2024-10-02T15:16:39.868Z
Learning: In the `middleware/session/session.go` file, the `saveSession()` method returns either `nil` or an error, so additional error wrapping in the `Save()` method is unnecessary.

Applied to files:

  • middleware/session/session.go
🔇 Additional comments (61)
ctx_test.go (1)

33-33: Test import normalization — OK

Alias removed; tests still use utils.* as expected.

middleware/limiter/limiter_fixed.go (1)

9-9: Limiter: import cleanup — OK; verify timestamp updater idempotence

Import alias removal looks good. Please confirm utils.StartTimeStampUpdater() is safe to call multiple times across middleware instances (guarded with sync.Once inside utils or here). If not, consider wrapping it.

middleware/cache/config.go (1)

8-8: Cache config import normalization — OK

No functional impact; default KeyGenerator continues using utils.CopyString.

listen_test.go (1)

19-19: Test import cleanup — OK

Alias removal is consistent; usage of utils.UnsafeString remains valid in tests.

ctx.go (1)

18-18: Verified: No aliased imports remain in codebase

The removal of the utils/v2 import alias from ctx.go (line 18) has been confirmed. Script output shows no leftover aliased imports across the repository, confirming the change is isolated and complete.

router_test.go (1)

21-21: LGTM! Import alias removal improves consistency.

The explicit utils alias has been removed in favor of the default package name. Since the package in github.com/gofiber/utils/v2 is named utils, all existing references (e.g., utils.StatusMessage on line 1476) remain valid without any functional changes.

bind.go (1)

10-10: LGTM! Import standardization looks good.

Removing the explicit import alias improves code consistency. The default package name utils from github.com/gofiber/utils/v2 ensures all existing references (e.g., lines 305-306: utils.ToLower, utils.UnsafeString) continue to work correctly.

client/hooks.go (1)

16-16: LGTM! Clean import style improvement.

The removal of the explicit utils alias aligns with Go's conventional import style. All usages (e.g., utils.UnsafeString on line 68, utils.CopyBytes on line 118) remain valid with the default package name.

middleware/cors/cors.go (1)

10-10: LGTM! Import cleanup improves consistency.

Removing the unnecessary import alias follows Go's idiomatic import style. The usage of utils.Trim (line 57) continues to work correctly with the default package name.

binder/resp_header.go (1)

4-4: LGTM! Import standardization is correct.

The import alias removal is consistent with the PR's goal of cleaning up import declarations. All utils.UnsafeString calls (lines 23-24) remain valid with the default package name.

middleware/proxy/proxy.go (1)

11-11: LGTM! Import cleanup looks good.

Removing the explicit import alias improves consistency across the codebase. All utility function calls (e.g., utils.UnsafeString on line 85, utils.CopyString on lines 185/188) remain functional with the default package name.

extractors/extractors.go (1)

33-33: LGTM! Import standardization is consistent.

The removal of the explicit utils alias aligns with the PR's objective of improving code consistency. The utils.EqualFold call (line 126) continues to work correctly with the default package name.

client/client.go (1)

24-24: LGTM! Import cleanup improves maintainability.

The removal of the explicit import alias is consistent with the codebase-wide refactoring. All utils type references (e.g., utils.JSONMarshal, utils.XMLMarshal) and function calls (e.g., utils.UnsafeString on line 379) remain valid with the default package name.

middleware/csrf/storage_manager.go (1)

11-11: LGTM! Removes redundant import alias.

The explicit utils alias is unnecessary since the package's default name is already utils. This cleanup improves code consistency.

binder/cbor.go (1)

4-4: LGTM! Removes redundant import alias.

The explicit alias is unnecessary and this change aligns with Go idioms.

middleware/limiter/limiter_sliding.go (1)

10-10: LGTM! Removes redundant import alias.

Consistent with the codebase-wide cleanup to remove unnecessary aliases.

log/default.go (1)

10-10: LGTM! Removes redundant import alias.

This change maintains consistency with the rest of the PR's cleanup effort.

mount.go (1)

12-12: LGTM! Removes redundant import alias.

The cleanup is correctly applied with no impact on functionality.

middleware/csrf/csrf.go (1)

13-13: LGTM! Removes redundant import alias.

Consistent with the broader refactoring effort across the codebase.

middleware/basicauth/basicauth.go (1)

11-11: LGTM! Removes redundant import alias.

The change correctly removes the unnecessary alias while preserving all usage sites.

middleware/requestid/config.go (1)

5-5: LGTM! Removes redundant import alias.

This completes the consistent cleanup across all affected files in the PR.

middleware/pprof/pprof.go (1)

8-8: LGTM! Import alias removal improves code consistency.

The explicit alias for github.com/gofiber/utils/v2 is unnecessary since the package's natural name is utils. This change simplifies the import declaration while maintaining all existing functionality.

client/cookiejar.go (1)

12-12: LGTM! Import style improvement aligns with codebase consistency.

Removing the redundant alias simplifies the import while preserving all utils.* references throughout the file (e.g., UnsafeString, TrimLeft, ToLower, CopyString).

middleware/session/config.go (1)

9-9: LGTM! Clean import simplification.

The default package name utils is sufficient, making the explicit alias unnecessary. Usage at line 95 (utils.UUIDv4) remains unchanged and valid.

middleware/session/session.go (1)

13-13: LGTM! Import consistency improvement.

Removing the alias aligns with the natural package name utils, maintaining all existing functionality without changes.

helpers_test.go (1)

14-14: LGTM! Test file import consistency.

The import simplification maintains all test functionality while improving code consistency across the codebase.

middleware/keyauth/keyauth.go (1)

10-10: LGTM! Import declaration simplified.

The change removes the redundant alias while preserving all functionality (e.g., utils.EqualFold at line 70).

middleware/adaptor/adaptor.go (1)

14-14: LGTM! Import style cleanup.

Removing the explicit alias maintains all existing usage (utils.StatusMessage at lines 213 and 221) while improving code consistency.

redirect.go (1)

13-13: LGTM! Consistent import simplification.

The alias removal aligns with the repository-wide cleanup while maintaining all existing functionality (e.g., utils.ToLower, utils.UnsafeString, utils.ParseVendorSpecificContentType at lines 145-146).

middleware/logger/default_logger.go (1)

10-10: LGTM! Import alias cleanup.

The removal of the explicit utils alias is correct since github.com/gofiber/utils/v2 defaults to package name utils. This change improves consistency across the codebase with no functional impact.

middleware/static/static.go (1)

16-16: LGTM! Import alias cleanup.

Removing the explicit utils alias is correct and maintains consistency with the codebase-wide refactoring.

binder/cookie.go (1)

4-4: LGTM! Import alias cleanup.

The change is correct and aligns with the codebase-wide import standardization.

req.go (2)

11-11: LGTM! Import alias cleanup.

The removal of the explicit utils alias is correct and part of the codebase-wide consistency improvement.


802-805: LGTM! Type refinement improves clarity.

Using the concrete RangeSet type instead of an anonymous struct provides better type safety and code clarity.

binder/mapping.go (1)

12-12: LGTM! Import alias cleanup.

The change correctly removes the unnecessary import alias while maintaining all functionality.

router.go (1)

13-13: LGTM! Import alias cleanup.

The import change is correct and aligns with the codebase-wide standardization effort.

middleware/csrf/config.go (1)

12-12: LGTM! Import alias cleanup.

The change correctly removes the explicit alias, maintaining consistency across the codebase.

middleware/csrf/csrf_test.go (1)

15-15: LGTM! Import alias cleanup.

The import change is correct and maintains all test functionality while improving codebase consistency.

binder/msgpack.go (1)

4-4: LGTM! Import alias removal is correct.

The explicit utils alias was redundant since the package's default name is already utils. The code continues to reference utils.MsgPackUnmarshal correctly.

middleware/idempotency/idempotency.go (1)

9-9: LGTM! Import simplification is correct.

Removing the redundant alias maintains the same package references (utils.CopyString, utils.CopyBytes, utils.ToLower) used throughout the middleware.

middleware/logger/utils.go (1)

8-8: LGTM! Alias removal is appropriate.

The change correctly removes the redundant alias while preserving all utils.UnsafeString references in the custom logger writer.

middleware/cache/manager_test.go (1)

8-8: LGTM! Test import updated correctly.

The import simplification maintains compatibility with utils.UUID() calls in the test cases.

internal/memory/memory_test.go (1)

7-7: LGTM! Benchmark import cleaned up correctly.

The alias removal is consistent with the codebase-wide refactoring and maintains utils.UUID() usage in the benchmark.

binder/form.go (1)

6-6: LGTM! Form binder import updated appropriately.

The redundant alias removal preserves the zero-allocation utils.UnsafeString calls used throughout the form binding logic.

res.go (1)

17-17: LGTM! Response handler import simplified correctly.

The alias removal is consistent across all utility function calls (utils.EqualFold, utils.TrimRight, utils.ToString, utils.CopyString, utils.StatusMessage, utils.UnsafeBytes, utils.GetMIME) throughout this file.

path.go (1)

18-18: LGTM! Route parser import cleaned up properly.

The import simplification maintains all utility references (utils.ToLowerBytes, utils.ToLower, utils.TrimRight, utils.EqualFold) used in the route parsing logic.

middleware/logger/template_chain.go (1)

7-7: LGTM! Import alias removal is correct.

The explicit utils alias is redundant since Go automatically uses the last path segment (utils) as the package name for github.com/gofiber/utils/v2. All references to utils.* throughout the file continue to work identically.

binder/xml.go (1)

6-6: LGTM! Import alias removal is correct.

The change removes the redundant explicit alias. The utils.XMLUnmarshal reference at line 11 continues to work with the default package name.

helpers.go (1)

24-24: LGTM! Import alias removal is correct.

The explicit utils alias is redundant. All references throughout the file (UnsafeString, UnsafeBytes, EqualFold, Trim, TrimRight, ToLowerBytes) continue to work with the default package name.

internal/storage/memory/memory.go (2)

10-10: LGTM! Import alias removal is correct.

The change removes the redundant explicit alias. All utils.* references throughout the file continue to work with the default package name.


60-61: Good addition: clarifying comments improve code documentation.

The added comments at lines 60-61 and 90-94 helpfully document the defensive copying behavior, making the intent explicit for future maintainers.

Also applies to: 90-94

client/response.go (1)

14-14: LGTM! Import alias removal is correct.

The explicit utils alias is redundant. All references (UnsafeString at lines 54, 66, 69, 72 and Trim at line 94) continue to work with the default package name.

binder/header.go (1)

4-4: LGTM! Import alias removal is correct.

The change removes the redundant explicit alias. The utils.UnsafeString calls at lines 22-23 continue to work with the default package name.

client/request.go (1)

19-19: LGTM! Import alias removal is correct.

The explicit utils alias is redundant. All utils.UnsafeString references throughout the file continue to work with the default package name.

client/client_test.go (1)

22-22: LGTM! Import alias removal is correct.

The change removes the redundant explicit alias. All utils.UnsafeString calls in the test assertions (lines 857, 888, 901, 929, 943) continue to work with the default package name.

binder/json.go (1)

4-4: LGTM! Redundant alias removed.

The import alias utils was unnecessary since the package's default name is already utils. This change improves code consistency.

register.go (1)

25-25: LGTM! Cleaner type assertion syntax.

The parentheses around Register were unnecessary. This change aligns with idiomatic Go style for compile-time interface assertions.

middleware/cache/cache.go (1)

17-17: LGTM! Redundant alias removed.

The import alias removal is consistent with the PR's objective. All usages of utils.* identifiers throughout the file remain unchanged and correct.

middleware/cache/cache_test.go (1)

21-21: LGTM! Test imports aligned with production code.

The import change is consistent with the corresponding production file changes.

app_test.go (1)

30-30: LGTM! Import cleanup applied consistently.

The redundant import alias has been removed, improving code consistency across the test suite.

app.go (1)

29-29: LGTM! Core file import standardized.

The import alias removal is correctly applied. All references to utils.* identifiers throughout the file (JSONMarshal, JSONUnmarshal, UnsafeBytes, UnsafeString, CopyBytes, StatusMessage, etc.) remain functional with the default package name.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR standardizes import statements across the codebase by removing import aliases for the github.com/gofiber/utils/v2 package. It also includes a refactoring change in req.go to use the named RangeSet type instead of an anonymous struct, and fixes minor formatting issues.

Key Changes:

  • Removed utils alias from all imports of github.com/gofiber/utils/v2 package
  • Replaced anonymous struct with the named RangeSet type in the Range method
  • Fixed unnecessary parentheses in type assertion

Reviewed Changes

Copilot reviewed 60 out of 60 changed files in this pull request and generated no comments.

Show a summary per file
File Description
app.go, app_test.go Removed utils import alias
bind.go Removed utils import alias
binder/*.go Removed utils import alias across all binder files
client/*.go Removed utils import alias across all client files
ctx.go, ctx_test.go Removed utils import alias
extractors/extractors.go Removed utils import alias
helpers.go, helpers_test.go Removed utils import alias
internal/memory/*.go, internal/storage/memory/memory.go Removed utils import alias and fixed indentation
listen_test.go Removed utils import alias
log/default.go Removed utils import alias
middleware/*.go Removed utils import alias across all middleware packages
mount.go, path.go, redirect.go Removed utils import alias
register.go Removed unnecessary parentheses in type assertion
req.go Removed utils import alias and replaced anonymous struct with RangeSet type
res.go, router.go, router_test.go Removed utils import alias

@gaby
Copy link
Member

gaby commented Nov 2, 2025

@arturmelanchyk In this same PR, modify the .golangci-lint.yml and remove internal from excluded paths.

Signed-off-by: Artur Melanchyk <13834276+arturmelanchyk@users.noreply.github.com>
@gaby
Copy link
Member

gaby commented Nov 2, 2025

We can add internal/tlstest back to the ignore list for linting/not format. But memory should be check.

Signed-off-by: Artur Melanchyk <13834276+arturmelanchyk@users.noreply.github.com>
@arturmelanchyk arturmelanchyk requested a review from gaby November 2, 2025 18:08
Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

LGTM

@gaby
Copy link
Member

gaby commented Nov 2, 2025

Ping @ReneWerner87

@ReneWerner87
Copy link
Member

Will check it tomorrow morning

@gaby
Copy link
Member

gaby commented Nov 2, 2025

/gemini review

@codex review

@gemini-code-assist
Copy link
Contributor

Thank you for invoking the review, @gaby. I've thoroughly reviewed the pull request, and it looks like a solid set of changes focused on code cleanliness and robustness.

Overall, the primary goal of removing the unneeded utils alias has been consistently applied across numerous files, which is a great cleanup effort. The changes in internal/storage/memory for exporting the Entry type and centralizing context error handling, as well as the hardening of TLS test configuration generation in internal/tlstest/tls.go, are significant improvements to correctness and maintainability.

I have one specific comment regarding the .golangci.yml changes, which directly addresses your previous comments:


File: .golangci.yml

Comment:

gaby, you mentioned that internal/tlstest could be added back to the ignore list for linting, while internal/storage/memory should be checked. The current change removes the entire internal directory from the excluded paths. This means both internal/tlstest and internal/storage/memory will now be linted and formatted.

If the intention is to exclude internal/tlstest specifically, you might want to add it back to the paths exclusion list. Otherwise, the current change will apply linting and formatting to all internal packages, which might be the desired outcome if internal/tlstest is now deemed ready for linting.

Severity: medium

    paths:
      - _msgp\.go
      - _msgp_test\.go
      - internal/tlstest
      - third_party$
      - builtin$
      - examples$
    paths:
      - _msgp\.go
      - _msgp_test\.go
      - internal/tlstest
      - third_party$
      - builtin$
      - examples$

Let me know if you'd like me to elaborate on any of these points or if you have further questions!

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ReneWerner87 ReneWerner87 added this to v3 Nov 3, 2025
@ReneWerner87 ReneWerner87 added this to the v3 milestone Nov 3, 2025
@ReneWerner87 ReneWerner87 merged commit 0be33db into gofiber:main Nov 3, 2025
20 of 21 checks passed
@github-project-automation github-project-automation bot moved this to Done in v3 Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants