Skip to content

docs: document utils package migration#3704

Merged
ReneWerner87 merged 10 commits intomainfrom
codex/2025-08-22-22-33-01
Aug 22, 2025
Merged

docs: document utils package migration#3704
ReneWerner87 merged 10 commits intomainfrom
codex/2025-08-22-22-33-01

Conversation

@ReneWerner87
Copy link
Member

Summary

  • document replacement of in-repo utils with github.com/gofiber/utils
  • move utils migration details to dedicated migration guide section with mapping table and example

Testing

  • make audit (fails: EncodeMsg passes lock by value)
  • make generate
  • make betteralign (fails: package requires newer Go version go1.25)
  • make modernize (fails: package requires newer Go version go1.25)
  • make format
  • make test
  • make markdown

https://chatgpt.com/codex/tasks/task_e_68a8e7a57d3c8326b4ae7856b0010af5

Copilot AI review requested due to automatic review settings August 22, 2025 22:33
@ReneWerner87 ReneWerner87 requested a review from a team as a code owner August 22, 2025 22:33
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 22, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Warning

Rate limit exceeded

@ReneWerner87 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 185eaf6 and ba69a12.

📒 Files selected for processing (1)
  • docs/whats_new.md (4 hunks)

Walkthrough

Documentation update to docs/whats_new.md adds a Utils section, a utils-migration guide, and enumerates public API changes for Fiber v3 (router methods, Route/Add, Test config, hooks, constants, configs, middleware shifts). It documents externalizing utils to github.com/gofiber/utils and introduces new helpers and generics.

Changes

Cohort / File(s) Summary
Documentation updates (Whats New + Migration)
docs/whats_new.md
Adds Utils section and migration guide (v2 → v3 utils import/mapping), lists public API signature changes (Router verbs, Route/Add, Test), hook deprecations, config/constant updates, middleware relocations, and introduces new helpers/generics and logger integration notes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant R as Router
  participant App as Fiber App

  Note over Dev,R: Register routes with new signatures (v3)
  Dev->>R: Get(path, handler, middleware...)
  R->>App: Add([GET], path, handler, middleware...)
  Dev->>R: Route(path)
  R-->>Dev: Register (for chaining)

  Note over Dev,App: Test API uses TestConfig (v3)
  Dev->>App: Test(req, TestConfig{...})
  App-->>Dev: *http.Response, error
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

v3

Suggested reviewers

  • gaby
  • sixcolors
  • efectn

Poem

A hop, a skip, a version three—
New routes to burrow, clean and free.
Utils moved to fields anew,
Hooks sprout early, late ones too.
I thump my log with gentle cheer,
Chaining paths from ear to ear. 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/2025-08-22-22-33-01

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @ReneWerner87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the documentation for Fiber v3 to reflect the significant change in how utility functions are handled. It clarifies that the internal utils package has been replaced by an external Go module, github.com/gofiber/utils. The changes include adding new sections to the 'What's New' and migration guides, providing clear instructions, function mapping tables, and code examples to assist developers in adapting their code to this new structure. The aim is to ensure a smooth transition for users migrating to Fiber v3 by providing comprehensive and accessible documentation for this core change.

Highlights

  • External utils module adoption: The documentation now clearly states that Fiber v3 has removed its built-in utils directory, opting instead to import utility helpers from the separate github.com/gofiber/utils module.
  • Comprehensive migration guide for utils: A new, dedicated section in the migration guide provides detailed steps for migrating from the old in-repo utils to the new external module, including import changes, a comprehensive mapping table of v2 functions to v3 replacements, and practical code examples.
  • Introduction of new utility helpers: The documentation highlights several new helper functions introduced in the github.com/gofiber/utils module, such as ParseInt, ParseUint, Walk, ReadFile, and Timestamp, which were not available in the previous in-repo utils.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 documents the migration from Fiber's built-in utils package to the external github.com/gofiber/utils module for v3. The documentation provides comprehensive migration guidance including function mapping and code examples.

Key changes:

  • Added utils section to the "What's New" overview with reference to migration guide
  • Created detailed migration guide with function mapping table showing v2 to v3 replacements
  • Included practical code examples demonstrating the migration process

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively documents the migration of the utils package to an external module. The added section in whats_new.md provides a clear and comprehensive guide for users, including a function mapping table and code examples. My review identifies a few areas for improvement to ensure accuracy and readability.

ReneWerner87 and others added 6 commits August 23, 2025 00:36
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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: 1

🧹 Nitpick comments (2)
docs/whats_new.md (2)

893-898: Add a quick “how to install” tip for the external utils module

Recommend adding an explicit go get step and noting the Go 1.25+ requirement to preempt user friction (your CI also flagged the newer Go requirement). This keeps the section self-contained and actionable.

Apply this diff to append a tip block under the first paragraph:

 ## 🛠️ Utils {#utils}

 Fiber v3 removes the built-in `utils` directory and now imports utility helpers from the separate [`github.com/gofiber/utils`](https://github.com/gofiber/utils) module. See the [migration guide](#utils-migration) for detailed replacement steps and examples.
 
 The `github.com/gofiber/utils` module also introduces new helpers like `ParseInt`, `ParseUint`, `Walk`, `ReadFile`, and `Timestamp`.
+
+:::tip Quick install
+Make sure you’re on Go 1.25 or newer, then add the module:
+
+```sh
+go get github.com/gofiber/utils@latest
+```
+:::

1914-1991: Tighten the Utils migration section: numbering, a clarifying note, and a couple of usage examples

  • The ordered list restarts at “1.” multiple times. Markdown auto-numbers, but using 1/2/3 reads cleaner in raw view.
  • Add a short note explaining the mapping convention (…Bytes → utils byte helpers; string funcs → standard library) to avoid confusion when scanning the table.
  • Include tiny examples for new helpers (ParseInt, Timestamp) to show intended use at a glance.

Apply this diff:

-### 🛠️ Utils {#utils-migration}
+### 🛠️ Utils {#utils-migration}
 
 Fiber v3 removes the in-repo `utils` package in favor of the external [`github.com/gofiber/utils`](https://github.com/gofiber/utils) module.
 
-1. Replace imports:
+1. Replace imports:
 
 ```go
 - import "github.com/gofiber/fiber/v2/utils"
 + import "github.com/gofiber/utils"

-1. Review function changes:
+2. Review function changes:
+
+Note: functions that previously ended with ...Bytes map to byte-slice helpers in github.com/gofiber/utils. Plain string helpers are now covered by the Go standard library (strings/bytes) where noted.

v2 function v3 replacement
AssertEqual removed; use testing libraries like stretchr/testify
ToLowerBytes utils.ToLowerBytes
ToUpperBytes utils.ToUpperBytes
TrimRightBytes utils.TrimRight
TrimLeftBytes utils.TrimLeft
TrimBytes utils.Trim
EqualFoldBytes utils.EqualFold
UUID utils.UUID
UUIDv4 utils.UUIDv4
FunctionName utils.FunctionName
GetArgument utils.GetArgument
IncrementIPRange utils.IncrementIPRange
ConvertToBytes utils.ConvertToBytes
CopyString utils.CopyString
CopyBytes utils.CopyBytes
ByteSize utils.ByteSize
ToString utils.ToString
UnsafeString utils.UnsafeString
UnsafeBytes utils.UnsafeBytes
GetString removed; use utils.ToString or the standard library
GetBytes removed; use utils.CopyBytes or []byte(s)
ImmutableString removed; strings are already immutable
GetMIME utils.GetMIME
ParseVendorSpecificContentType utils.ParseVendorSpecificContentType
StatusMessage utils.StatusMessage
IsIPv4 utils.IsIPv4
IsIPv6 utils.IsIPv6
ToLower utils.ToLower
ToUpper utils.ToUpper
TrimLeft strings.TrimLeft
Trim strings.Trim
TrimRight strings.TrimRight
EqualFold strings.EqualFold
StartTimeStampUpdater utils.StartTimeStampUpdater (new utils.Timestamp provides the current value)

-1. Update your code. For example:
+3. Update your code. For example:

// v2
import oldutils "github.com/gofiber/fiber/v2/utils"

func demo() {
    b := oldutils.TrimBytes([]byte(" fiber "))
    id := oldutils.UUIDv4()
    s := oldutils.GetString([]byte("foo"))
}

// v3
import (
    "github.com/gofiber/utils"
    "strings"
)

func demo() {
    b := utils.Trim([]byte(" fiber "))
    id := utils.UUIDv4()
    s := utils.ToString([]byte("foo"))
    t := strings.TrimRight("bar  ", " ")
}

-The github.com/gofiber/utils module also introduces new helpers like ParseInt, ParseUint, Walk, ReadFile, and Timestamp.
+The github.com/gofiber/utils module also introduces new helpers like ParseInt, ParseUint, Walk, ReadFile, and Timestamp.
+
+go +// Examples +v, err := utils.ParseInt[int]("42") // -> 42, nil +nowUnixMilli := utils.Timestamp() // current cached unix ms (updated by StartTimeStampUpdater) +


</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: CodeRabbit UI

**Review profile**: CHILL

**Plan**: Pro

**💡 Knowledge Base configuration:**

- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between edd70830728f4f09bcc2421dce07e7934f91fd03 and 185eaf6e0dfda33c67c71158227aaca2552b1992.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `docs/whats_new.md` (4 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>📓 Path-based instructions (1)</summary>

<details>
<summary>docs/**</summary>


**📄 CodeRabbit inference engine (.github/copilot-instructions.md)**

> Review and update the contents of the `docs` folder if necessary when modifying code

Files:
- `docs/whats_new.md`

</details>

</details><details>
<summary>🧠 Learnings (3)</summary>

<details>
<summary>📓 Common learnings</summary>

Learnt from: ckoch786
PR: #3230
File: docs/whats_new.md:944-951
Timestamp: 2024-12-15T19:56:45.935Z
Learning: Detailed usage examples and explanations for new methods like RemoveRoute and RemoveRouteByName are documented in docs/api/app.md, so it's unnecessary to duplicate them in docs/whats_new.md.


Learnt from: ReneWerner87
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.


</details>
<details>
<summary>📚 Learning: 2024-11-15T07:56:21.623Z</summary>

Learnt from: ReneWerner87
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:**
- `docs/whats_new.md`

</details>
<details>
<summary>📚 Learning: 2024-11-10T23:44:13.704Z</summary>

Learnt from: gaby
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:**
- `docs/whats_new.md`

</details>

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (2)</summary><blockquote>

<details>
<summary>docs/whats_new.md (2)</summary><blockquote>

`27-27`: **TOC entry for Utils looks good**

The anchor matches the new section id (`#utils`) introduced below. No action needed.

---

`1414-1414`: **Migration guide TOC entry is correct**

The link (`#utils-migration`) correctly points to the new migration subsection id below. Looks good.

</blockquote></details>

</blockquote></details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

ReneWerner87 and others added 3 commits August 23, 2025 00:38
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ReneWerner87 ReneWerner87 merged commit 5c403cd into main Aug 22, 2025
2 checks passed
@ReneWerner87 ReneWerner87 deleted the codex/2025-08-22-22-33-01 branch August 22, 2025 22:42
@ReneWerner87 ReneWerner87 added this to v3 Aug 22, 2025
@ReneWerner87 ReneWerner87 added this to the v3 milestone Aug 22, 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.

3 participants