Skip to content

🩹 Fix: golangci-lint issue for go1.25.0#3775

Merged
ReneWerner87 merged 18 commits intogofiber:mainfrom
laughing-nerd:fix/golangci-lint
Oct 20, 2025
Merged

🩹 Fix: golangci-lint issue for go1.25.0#3775
ReneWerner87 merged 18 commits intogofiber:mainfrom
laughing-nerd:fix/golangci-lint

Conversation

@laughing-nerd
Copy link
Contributor

@laughing-nerd laughing-nerd commented Oct 2, 2025

Description

Updated the Makefile to use the latest version of golangci-lint along with necessary migrations. I've followed this migration doc for migrating the old config of golangci-lint.

Fixes #3731

Changes introduced

  • fixed golangci-lint

  • updated code to fix lint errors

  • 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

@welcome
Copy link

welcome bot commented Oct 2, 2025

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 2, 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.

Walkthrough

Added an explicit error for unsupported client body types, updated parser to return it; moved session Store fields (Extractor, IdleTimeout) to top-level; upgraded lint tooling; converted many tests to use emptiness/len matchers and modernized goroutine patterns; several small refactors to logging, formatting, routing, and helpers.

Changes

Cohort / File(s) Summary
Build tooling: lint target
Makefile
Use GOVERSION for GOTOOLCHAIN; upgrade golangci-lint to v2.5.0 and adopt v2 module path and updated invocation.
Client: body parsing & request helpers
client/core.go, client/hooks.go, client/hooks_test.go, client/request.go, client/request_test.go, client/client_test.go
Add exported ErrBodyTypeNotSupported; parserRequestBody now returns it for unknown body types; refactor Request.File, header/form accessors; update related tests and add unsupported-body-type test.
Session middleware API & tests
middleware/session/store.go, middleware/session/session_test.go, middleware/session/store_test.go
Expose Store.Extractor and move IdleTimeout to Store.IdleTimeout (top-level); update tests to use new field locations and adjusted extraction logic.
Tests: assertion and concurrency modernizations
Multiple *_test.go (e.g., app_test.go, bind_test.go, binder/*, ctx_test.go, helpers_test.go, listen_test.go, router_test.go, state_test.go, path_test.go, mount_test.go, prefork_test.go, many middleware/**/_test.go, ...)
Replace literal "" checks with require.Empty/require.Len, convert some t.Errorft.Error, remove some nolint directives, and replace manual wg.Add/wg.Done with wg.Go(func(){...}) across many tests.
Request/Response/Context small changes
req.go, res.go, ctx.go, ctx_test.go
Add explicit default/no-op switch branches, annotate some Accepts calls with nolint staticcheck, and minor guard adjustments; tests updated for emptiness/len assertions.
Routing & path parsing tweaks
path.go, path_test.go
Consolidate early-match checks for / and /*, add default branches in internal switches, refine const/parameter matching guards.
Formatting, logging & panic output
log/default.go, middleware/logger/default_logger.go, middleware/logger/tags.go, middleware/recover/recover.go
Replace temporary fmt.Sprintf/fmt.Sprint usages with direct fmt.Fprintf/fmt.Fprint calls writing to buffers; minor refactor preserving behavior.
Listener startup & output capture
listen.go, listen_test.go
Trim startup ASCII art and switch test output capture to channel-based synchronization; no functional listener change.
Helpers & small refactors
helpers.go, middleware/cors/cors.go, middleware/adaptor/adaptor_test.go, others
Negated-condition rewrite, added default switch cases to clarify behavior, small declaration style tweaks (short var), and other minor adjustments.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Caller
    participant ClientReq as Request
    participant Parser

    Caller->>ClientReq: parserRequestBody(bodyType)
    ClientReq->>Parser: switch by bodyType
    alt supported type
        Parser-->>ClientReq: parse success (nil)
        ClientReq-->>Caller: proceed
    else unsupported
        Parser-->>ClientReq: ErrBodyTypeNotSupported
        ClientReq-->>Caller: return error
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • sixcolors
  • ReneWerner87
  • gaby

Poem

Thump-thump, I hopped through lines of code,
Lint tuned, tests snug in their new mode.
Unsupported bodies now politely decline,
Sessions rearranged like carrots in a line.
A patch of fixes — tidy, quick, and fine 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes Check ❓ Inconclusive While most changes appear directly related to fixing lint errors from the golangci-lint upgrade (such as adding default cases in switches, updating assertion styles in tests, and improving error handling), the PR includes some changes that appear to extend beyond strict lint fixes. Notably, client/core.go adds a new exported error variable ErrBodyTypeNotSupported, and middleware/session includes architectural refactoring that moves IdleTimeout from Store.Config.IdleTimeout to a top-level Store.IdleTimeout field. These public API changes represent design improvements that go beyond the stated objective of upgrading golangci-lint and fixing resulting lint errors. Clarification is needed on whether the new ErrBodyTypeNotSupported export and the IdleTimeout API refactoring are required by golangci-lint v2 migration rules or represent scope creep beyond the PR's stated objectives. If these are architectural improvements not strictly required for the lint fix, they should either be justified in the description or moved to a separate PR to maintain focus on the maintenance task.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "🩹 Fix: golangci-lint issue for go1.25.0" clearly and concisely identifies the primary change: upgrading golangci-lint to address Go 1.25 compatibility issues. The title is specific enough to convey the main objective and directly relates to the changeset, which involves updating the Makefile to use golangci-lint v2.5.0 and fixing resulting lint errors. The emoji and wording appropriately indicate this is a maintenance fix rather than a feature.
Linked Issues Check ✅ Passed The PR directly addresses linked issue #3731, which requires upgrading golangci-lint to a version compatible with Go 1.25 and applying required configuration migrations to restore the ability to run make lint locally. The changes satisfy these requirements: the Makefile was updated to upgrade golangci-lint from v1.64.7 to v2.5.0, configuration migrations were applied following the official migration guide, and extensive code changes were made throughout test files and production code to resolve lint errors introduced by the new version. The PR successfully fulfills the stated objectives of the linked issue.
Description Check ✅ Passed The PR description provides essential information including a clear explanation of the changes (updated Makefile and fixed lint errors), a reference to the migration guide followed, and the linked issue #3731. The description structure mostly aligns with the template, though the "Type of change" section was not completed with any selection—this is a minor gap since the actual description adequately explains the work. The Migration Guide checkbox is marked as completed, which is appropriate. Overall, the description is sufficiently complete to understand the PR's purpose and scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@laughing-nerd laughing-nerd marked this pull request as ready for review October 2, 2025 07:39
@laughing-nerd laughing-nerd requested a review from a team as a code owner October 2, 2025 07:39
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.

The lint workflow in .github/workflows needs to be updated with the new version

@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 91.30435% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.06%. Comparing base (c6e6d72) to head (0c8342f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
path.go 71.42% 2 Missing ⚠️
req.go 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3775      +/-   ##
==========================================
+ Coverage   92.02%   92.06%   +0.04%     
==========================================
  Files         115      115              
  Lines       12249    12257       +8     
==========================================
+ Hits        11272    11285      +13     
+ Misses        712      709       -3     
+ Partials      265      263       -2     
Flag Coverage Δ
unittests 92.06% <91.30%> (+0.04%) ⬆️

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.

@laughing-nerd laughing-nerd requested a review from gaby October 2, 2025 12:39
@gaby
Copy link
Member

gaby commented Oct 2, 2025

@laughing-nerd The CI is now able to run, can you check the failures

@laughing-nerd
Copy link
Contributor Author

@gaby The failures are due to lint issues in the code. Do you want me to fix them in this PR or raise a separate PR to fix the issues?

@ReneWerner87
Copy link
Member

In this PR otherwise the default branch is Red.

@gaby gaby added this to v3 Oct 3, 2025
@gaby gaby added this to the v3 milestone Oct 3, 2025
@gaby gaby moved this to In Progress in v3 Oct 3, 2025
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: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
middleware/session/session_test.go (1)

1418-1424: Compilation error: sync.WaitGroup has no Go method.

The code calls wg.Go(func() { ... }) on line 1424, but sync.WaitGroup from the standard library does not have a Go method. This will cause a compilation error.

Apply this diff to fix the issue:

 	for range numGoroutines {
-		wg.Go(func() {
+		wg.Add(1)
+		go func() {
 			defer wg.Done()

Alternatively, if you intend to use a helper with a Go method, import golang.org/x/sync/errgroup and replace:

-	var wg sync.WaitGroup
+	var eg errgroup.Group

Then update the loop to use eg.Go and handle errors appropriately. However, note that errgroup.Group.Go expects a function returning error, so you'd need to adjust the goroutine body.

path.go (1)

516-523: Skip constraints for empty optional parameters. The current check

if !segment.IsOptional || i != 0 {
    // …
}

still applies constraints on an empty optional segment (breaking /api/v1/params: []string{""}, match: true). Change it to:

if !segment.IsOptional || params[paramsIterator] != "" {
    // …
}

so constraints run only when a value exists.

🧹 Nitpick comments (3)
path.go (1)

187-190: The early-match change for "/*" is confined to RoutePatternMatch (a standalone helper used only in tests/benchmarks), not the core routing logic. The RoutePatternMatch helper isn’t widely exercised for generic wildcard matching in path_test.go, and its existing tests focus on literal "/*" cases. No tests verify that RoutePatternMatch("any/path", "/*") returns true.

This behavior change is intentional (aligns with wildcard semantics) but untested for non-literal paths. Add or update a test in path_test.go:

// in Test_RoutePatternMatch
testCaseFn("/*", []routeTestCase{
    {url: "/", match: true},
    {url: "/foo", match: true},
    {url: "/foo/bar", match: true},
})
helpers.go (1)

236-236: LGTM! Refactored condition improves readability.

The rewritten condition if rs[0] != "*" && !utils.EqualFold(rs[0], ts[0]) is logically equivalent to the original if !(rs[0] == "*" || utils.EqualFold(rs[0], ts[0])) by De Morgan's law, but is more direct and easier to follow.

middleware/logger/tags.go (1)

149-149: LGTM! Direct buffer writes reduce allocations.

Replacing fmt.Sprintf with fmt.Fprintf for writing formatted output directly to the buffer eliminates intermediate string allocation, improving performance in the logging hot path. The Buffer interface supports this pattern via its Write methods.

Also applies to: 179-179, 185-185, 192-192, 201-201

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8127494 and 68f2e72.

⛔ Files ignored due to path filters (2)
  • .github/workflows/linter.yml is excluded by !**/*.yml
  • .golangci.yml is excluded by !**/*.yml
📒 Files selected for processing (44)
  • app_test.go (7 hunks)
  • bind_test.go (4 hunks)
  • binder/binder_test.go (1 hunks)
  • binder/mapping_test.go (1 hunks)
  • client/client_test.go (11 hunks)
  • client/core.go (1 hunks)
  • client/hooks.go (1 hunks)
  • client/hooks_test.go (4 hunks)
  • client/request.go (3 hunks)
  • client/request_test.go (7 hunks)
  • ctx.go (1 hunks)
  • ctx_test.go (18 hunks)
  • extractors/extractors_test.go (2 hunks)
  • helpers.go (2 hunks)
  • helpers_test.go (2 hunks)
  • hooks_test.go (1 hunks)
  • listen.go (2 hunks)
  • listen_test.go (1 hunks)
  • log/default.go (1 hunks)
  • middleware/adaptor/adaptor_test.go (1 hunks)
  • middleware/cache/cache_test.go (1 hunks)
  • middleware/compress/compress_test.go (12 hunks)
  • middleware/cors/cors.go (1 hunks)
  • middleware/cors/cors_test.go (22 hunks)
  • middleware/csrf/config_test.go (1 hunks)
  • middleware/envvar/envvar_test.go (2 hunks)
  • middleware/helmet/helmet_test.go (4 hunks)
  • middleware/idempotency/idempotency_test.go (1 hunks)
  • middleware/keyauth/keyauth_test.go (2 hunks)
  • middleware/limiter/limiter_test.go (7 hunks)
  • middleware/logger/default_logger.go (1 hunks)
  • middleware/logger/logger_test.go (3 hunks)
  • middleware/logger/tags.go (3 hunks)
  • middleware/recover/recover.go (1 hunks)
  • middleware/session/session_test.go (6 hunks)
  • middleware/session/store_test.go (4 hunks)
  • middleware/static/static_test.go (6 hunks)
  • mount_test.go (1 hunks)
  • path.go (5 hunks)
  • path_test.go (1 hunks)
  • req.go (5 hunks)
  • res.go (3 hunks)
  • router_test.go (2 hunks)
  • state_test.go (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • ctx.go
  • path_test.go
  • app_test.go
  • mount_test.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Format Go code using gofumpt (enforced via make format)
Ensure code passes golangci-lint checks (enforced via make lint)
Optimize struct field alignment using betteralign (enforced via make betteralign)
Modernize Go code using gopls modernize (enforced via make modernize)

Files:

  • client/core.go
  • middleware/csrf/config_test.go
  • middleware/logger/default_logger.go
  • middleware/compress/compress_test.go
  • extractors/extractors_test.go
  • path.go
  • middleware/idempotency/idempotency_test.go
  • middleware/envvar/envvar_test.go
  • middleware/recover/recover.go
  • middleware/logger/logger_test.go
  • req.go
  • router_test.go
  • client/hooks.go
  • log/default.go
  • client/request.go
  • helpers_test.go
  • bind_test.go
  • client/request_test.go
  • middleware/adaptor/adaptor_test.go
  • state_test.go
  • client/hooks_test.go
  • helpers.go
  • middleware/keyauth/keyauth_test.go
  • binder/binder_test.go
  • hooks_test.go
  • middleware/cors/cors_test.go
  • binder/mapping_test.go
  • res.go
  • middleware/limiter/limiter_test.go
  • middleware/session/store_test.go
  • middleware/static/static_test.go
  • middleware/cache/cache_test.go
  • listen_test.go
  • middleware/cors/cors.go
  • listen.go
  • middleware/logger/tags.go
  • ctx_test.go
  • middleware/helmet/helmet_test.go
  • middleware/session/session_test.go
  • client/client_test.go
🧠 Learnings (3)
📚 Learning: 2024-12-13T08:14:22.851Z
Learnt from: efectn
PR: gofiber/fiber#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:

  • client/request_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.

Applied to files:

  • middleware/cors/cors_test.go
  • middleware/session/session_test.go
📚 Learning: 2024-09-25T17:05:06.991Z
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/middleware_test.go:190-191
Timestamp: 2024-09-25T17:05:06.991Z
Learning: When testing session `IdleTimeout` expiration, it's acceptable to use `time.Sleep` to simulate the passage of time in tests.

Applied to files:

  • middleware/session/session_test.go
🧬 Code graph analysis (16)
middleware/compress/compress_test.go (1)
constants.go (1)
  • HeaderContentEncoding (212-212)
middleware/logger/logger_test.go (1)
constants.go (1)
  • MethodGet (5-5)
req.go (1)
constants.go (6)
  • StatusUnsupportedMediaType (88-88)
  • ErrNotImplemented (149-149)
  • StatusNotImplemented (104-104)
  • StatusBadRequest (73-73)
  • StatusRequestedRangeNotSatisfiable (89-89)
  • HeaderContentRange (234-234)
router_test.go (1)
constants.go (2)
  • MethodGet (5-5)
  • StatusOK (52-52)
client/hooks.go (1)
client/core.go (1)
  • ErrBodyTypeNotSupported (256-256)
client/request_test.go (1)
client/request.go (2)
  • Cookie (778-778)
  • PathParam (826-826)
client/hooks_test.go (1)
client/request.go (2)
  • Header (708-710)
  • Cookie (778-778)
middleware/cors/cors_test.go (1)
constants.go (6)
  • HeaderAccessControlAllowCredentials (198-198)
  • HeaderAccessControlMaxAge (203-203)
  • HeaderAccessControlExposeHeaders (202-202)
  • HeaderAccessControlAllowHeaders (199-199)
  • HeaderAccessControlAllowOrigin (201-201)
  • HeaderAccessControlAllowMethods (200-200)
res.go (1)
constants.go (1)
  • HeaderAccept (190-190)
middleware/limiter/limiter_test.go (1)
constants.go (3)
  • MethodGet (5-5)
  • StatusOK (52-52)
  • HeaderRetryAfter (273-273)
middleware/session/store_test.go (1)
extractors/extractors.go (1)
  • Extractor (67-73)
middleware/static/static_test.go (1)
constants.go (2)
  • HeaderCacheControl (168-168)
  • HeaderContentEncoding (212-212)
middleware/logger/tags.go (3)
middleware/logger/config.go (2)
  • Buffer (108-119)
  • Config (12-99)
ctx_interface_gen.go (1)
  • Ctx (18-426)
middleware/logger/data.go (1)
  • Data (9-18)
ctx_test.go (3)
req_interface_gen.go (1)
  • Req (12-188)
constants.go (4)
  • HeaderAccept (190-190)
  • HeaderContentType (216-216)
  • HeaderAcceptLanguage (193-193)
  • HeaderLink (271-271)
req.go (1)
  • Params (619-625)
middleware/helmet/helmet_test.go (1)
constants.go (4)
  • HeaderContentSecurityPolicy (237-237)
  • HeaderReferrerPolicy (229-229)
  • HeaderPermissionsPolicy (241-241)
  • HeaderStrictTransportSecurity (244-244)
client/client_test.go (1)
client/request.go (2)
  • Cookie (778-778)
  • PathParam (826-826)
🔇 Additional comments (50)
helpers_test.go (1)

21-21: LGTM! Test assertion improvements align with best practices.

The change from require.Equal(t, "", ...) to require.Empty(t, ...) improves test readability and semantics. require.Empty is more expressive and aligns with testifylint recommendations enforced by golangci-lint.

Also applies to: 23-23, 25-29, 35-35, 57-58, 63-63, 71-71

middleware/csrf/config_test.go (1)

162-162: LGTM! Idiomatic assertion style.

The change from require.Equal(t, "", chained.Key) to require.Empty(t, chained.Key) is more idiomatic and aligns with testify best practices for empty-value assertions. This likely addresses a golangci-lint rule (e.g., testifylint) enforcing consistent empty checks.

middleware/adaptor/adaptor_test.go (1)

237-237: LGTM!

The change from explicit type declaration to short variable declaration is idiomatic Go and aligns with best practices. This likely resolves a golangci-lint warning (e.g., S1021: should omit type from declaration).

middleware/cache/cache_test.go (1)

913-913: LGTM! Test assertion style improved.

The change from checking equality with an empty string to using require.Empty() is more idiomatic for testify assertions and aligns with the PR's objective to address golangci-lint issues. The test logic remains functionally equivalent—both lines correctly verify that HEAD responses return empty bodies per HTTP specification.

Also applies to: 920-920

middleware/keyauth/keyauth_test.go (1)

162-163: LGTM! Explicit default case improves clarity.

The addition of an explicit default branch for paramExtractorName makes the code more maintainable and satisfies exhaustive switch-case linting rules. Since param-based extraction configures the URL path (lines 132-134) rather than headers or body, this no-op default accurately documents the intentional absence of header/body setup.

extractors/extractors_test.go (2)

312-312: LGTM! Improved test assertion.

The change from require.Equal(t, "", ...) to require.Empty(t, ...) is more idiomatic and aligns with golangci-lint best practices for Go 1.25.0. This assertion style is clearer and handles nil values correctly.


659-659: LGTM! Consistent test assertion improvement.

This change mirrors the improvement at line 312, ensuring consistency across the test file. Using require.Empty(t, ...) is the idiomatic approach for emptiness checks.

middleware/envvar/envvar_test.go (2)

24-24: LGTM! Improved assertion style.

Using require.Empty is more idiomatic than comparing to an empty string and clearly expresses the intent to check for emptiness. This change aligns with testifylint best practices.


119-119: LGTM! Improved assertion style.

Using require.Empty is more idiomatic than comparing to an empty string. This change clearly expresses the intent to verify that the HEAD request returns no body and aligns with testifylint best practices.

middleware/recover/recover.go (1)

11-13: LGTM! Cleaner panic handler implementation.

The refactor from fmt.Sprintf + write to direct fmt.Fprintf(os.Stderr, ...) eliminates an intermediate string allocation and removes the need for the nolint:errcheck directive. The output remains identical, and the code is now more idiomatic and efficient.

res.go (1)

371-371: LGTM: Consistent refactor.

The change from r.c.DefaultReq.Accepts(...) to r.c.Accepts(...) is consistent with the refactoring in the Format method and improves API consistency.

middleware/session/store_test.go (2)

22-66: LGTM! Public API field path updated correctly.

The test correctly exercises session ID extraction via cookie, header, and URL query using the new top-level store.Extractor.Key field path, aligning with the Store API refactor.


78-93: LGTM! Security regression test updated correctly.

The test properly validates that invalid session IDs trigger regeneration, using the updated store.Extractor.Key field path.

middleware/session/session_test.go (4)

768-769: LGTM! Public API field path updated correctly.

The test correctly forces IdleTimeout to a longer value using the new top-level store.IdleTimeout field to verify that AbsoluteTimeout takes precedence, aligning with the Store API refactor.


898-898: LGTM! Improved assertion style.

Using require.Empty to verify the absence of the session_id header after destruction is more idiomatic than an equality check.


1033-1035: LGTM! Improved cookie attribute validation.

Using strings.SplitSeq with range iteration to verify cookie attributes order-independently is more robust than substring matching and correctly handles attribute ordering variations.


1182-1183: LGTM! Improved assertion style.

Using require.Empty to verify the absence of session_id in both response and request headers after reset is more idiomatic than equality checks.

path.go (2)

356-364: LGTM! Lint fix for exhaustive switch.

The explicit default case satisfies linter requirements (likely exhaustive or similar) without changing behavior. The "do nothing" comment clearly documents the intent.


504-506: LGTM! Improved bounds checking.

The condition now explicitly checks i > partLen before slicing, preventing potential out-of-bounds panics. The short-circuit OR operator ensures safe evaluation.

hooks_test.go (1)

22-38: LGTM!

The assertion update from require.Equal(t, "", r.Name) to require.Empty(t, r.Name) improves readability and aligns with idiomatic test style.

binder/mapping_test.go (1)

379-398: LGTM!

The assertion update from require.Equal(t, "", m["empty"]) to require.Empty(t, m["empty"]) improves readability and aligns with idiomatic test style.

middleware/logger/default_logger.go (1)

38-47: LGTM!

The refactor from buf.WriteString(fmt.Sprintf(...)) to fmt.Fprintf(buf, ...) reduces allocations by writing directly to the buffer without intermediate string allocation, aligning with other logging components in the repository.

binder/binder_test.go (1)

72-83: LGTM!

The assertion update from require.Equal(t, "", m2["empty"]) to require.Empty(t, m2["empty"]) improves readability and aligns with idiomatic test style.

client/core.go (1)

256-256: LGTM!

The new exported error variable ErrBodyTypeNotSupported is well-named with a clear error message, enabling explicit error handling for unsupported body types in client/hooks.go.

middleware/static/static_test.go (5)

93-93: LGTM!

The assertion update to require.Empty for the Cache-Control header check improves readability and aligns with idiomatic test style.


137-137: LGTM!

The assertion update to require.Empty for the Cache-Control header check improves readability and aligns with idiomatic test style.


167-177: LGTM!

The assertion updates to require.Empty for the Cache-Control header checks improve readability and align with idiomatic test style.


795-795: LGTM!

The assertion update to require.Empty for the Content-Encoding header check improves readability and aligns with idiomatic test style.


826-826: LGTM!

The assertion update to require.Empty for the Content-Encoding header check improves readability and aligns with idiomatic test style.

middleware/logger/logger_test.go (2)

137-137: LGTM: Test assertion style improvement.

The change from require.Equal(t, "", buf.String()) to require.Empty(t, buf.String()) is more idiomatic and aligns with the PR-wide test assertion improvements.


833-835: LGTM: Concurrency pattern modernized.

The change from manual wg.Add(1) and wg.Done() to wg.Go(func() {...}) is cleaner and less error-prone. This aligns with similar concurrency improvements throughout the test suite.

state_test.go (1)

54-54: LGTM: Test assertion style improvements.

The changes from require.Equal(t, "", s) to require.Empty(t, s) are more idiomatic and align with the PR-wide test assertion improvements. The functional behavior remains unchanged.

Also applies to: 59-59

middleware/cors/cors.go (1)

50-50: LGTM: Simplified initialization logic.

The change from a two-step initialization to a single boolean expression is cleaner and more concise while maintaining the same logical behavior.

client/request.go (3)

538-547: LGTM: Control flow restructured but functionally equivalent.

The switch statement restructuring maintains the same logic:

  • Empty name still matches by base path
  • Non-empty name matches by equality
  • Default case continues iteration

922-922: LGTM: Simplified method call.

The change from f.Args.Del(v) to f.Del(v) is cleaner. Since FormData wraps *fasthttp.Args and likely has a Del method that delegates to Args.Del, this is an improvement.


716-716: Resolve: Header.All() correctly delegates to fasthttp.RequestHeader.All The embedded *fasthttp.RequestHeader promotes its All() method, so h.All() returns the same data as h.RequestHeader.All().

client/request_test.go (1)

459-459: LGTM: Test assertion style improvements.

All changes from require.Equal(t, "", ...) to require.Empty(t, ...) are more idiomatic and align with the PR-wide test assertion improvements. Based on learnings: prefer using require methods from the testify package for assertions.

Also applies to: 563-563, 578-579, 925-925, 979-979, 1625-1625, 1779-1779

listen_test.go (1)

662-669: LGTM: Concurrency pattern modernized.

The change from manual wg.Add(1) and wg.Done() to wg.Go(func() {...}) is cleaner and less error-prone. This aligns with similar concurrency improvements throughout the test suite.

middleware/compress/compress_test.go (1)

183-183: LGTM: Test assertion style improvements.

All changes improve test assertion idioms:

  • Replacing require.Equal(t, "", ...) with require.Empty(t, ...) for empty string checks
  • Replacing require.Equal(t, len(body), len(filedata)) with require.Len(t, body, len(filedata)) for length checks

These changes align with the PR-wide test assertion improvements and make the test intent clearer.

Also applies to: 188-188, 412-412, 449-449, 471-471, 493-493, 513-513, 532-532, 553-553, 574-574, 595-595, 630-630, 651-651

listen.go (1)

301-302: LGTM! Context-aware listening improves graceful shutdown.

Replacing direct net.Listen with net.ListenConfig{}.Listen(cfg.GracefulContext, ...) enables context-aware listener creation for non-TLS paths. This respects cancellation from cfg.GracefulContext and aligns with the graceful shutdown flow initiated at line 216.

helpers.go (1)

447-448: LGTM! Default case documents existing behavior.

The added default case explicitly documents that all other characters are ignored in the quoted parsing path. This clarifies intent without changing logic.

router_test.go (1)

1042-1042: LGTM! Empty check is more idiomatic.

Replacing the empty string comparison with require.Empty is consistent with the broader test suite migration and is more explicit about checking for emptiness.

middleware/limiter/limiter_test.go (2)

239-239: LGTM! Using require.NoError in goroutines improves test reliability.

Switching from assert.NoError to require.NoError inside concurrent test goroutines ensures immediate test failure on error, preventing misleading subsequent assertions and potential race conditions.

Also applies to: 243-243, 278-278, 282-282, 320-320, 324-324, 361-361, 365-365


1006-1008: LGTM! Empty checks are more explicit for header absence.

Replacing direct empty string comparisons with require.Empty for header checks when DisableHeaders is true is more idiomatic and clearly expresses the intent that these headers should not be present.

Also applies to: 1018-1021

middleware/cors/cors_test.go (1)

51-51: LGTM! Empty checks improve test clarity.

Replacing direct empty string comparisons with require.Empty for header assertions is more idiomatic and clearly expresses the intent that these headers should be absent. This aligns with the broader test suite migration to explicit emptiness checks.

Also applies to: 83-83, 115-116, 126-127, 184-184, 195-195, 263-263, 364-364, 377-377, 390-390, 532-532, 611-611, 628-628, 643-644, 692-692, 745-745, 1029-1029, 1032-1032, 1042-1042, 1057-1057, 1072-1072, 1088-1088, 1105-1105

middleware/helmet/helmet_test.go (1)

26-26: LGTM! Empty checks are more explicit for header absence.

Replacing direct empty string comparisons with require.Empty for security header assertions is more idiomatic and clearly expresses the intent that these headers should be absent in the tested scenarios. This aligns with the broader test suite migration to explicit emptiness checks.

Also applies to: 28-28, 83-83, 151-151, 185-185, 233-233

client/hooks_test.go (3)

202-205: LGTM! Default case improves test robustness.

Adding a default case with t.Fatalf ensures the test fails immediately if an unexpected query parameter value is encountered, providing clearer diagnostic information and preventing silent test failures.


415-415: LGTM! Empty checks are more idiomatic.

Replacing direct empty string comparisons with require.Empty for cookie value assertions is consistent with the broader test suite migration and more clearly expresses the intent.

Also applies to: 437-437


624-624: LGTM! Direct buffer write reduces allocations.

Replacing fmt.Sprintf with fmt.Fprintf for writing formatted logs directly to the buffer eliminates intermediate string allocation, improving efficiency in the test logger.

bind_test.go (1)

220-220: LGTM: Idiomatic assertion style.

The switch from require.Equal(t, "", field) to require.Empty(t, field) improves test readability and aligns with Go testing best practices. This is likely addressing a golangci-lint recommendation for more idiomatic empty-value assertions.

Also applies to: 477-477, 1141-1141, 1660-1660

@gaby gaby requested a review from Copilot October 4, 2025 04:42
@gaby
Copy link
Member

gaby commented Oct 4, 2025

/gemini review

@laughing-nerd
Copy link
Contributor Author

some tests are failing locally. Checking the issue.

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 pull request updates golangci-lint to version 2.5.0 to fix compatibility issues with Go 1.25.0. The update includes migrating the golangci-lint configuration file to the new v2 format and addressing numerous lint violations throughout the codebase.

Key changes include:

  • Updated golangci-lint from v1.64.7 to v2.5.0 in Makefile and GitHub Actions workflow
  • Migrated .golangci.yml configuration file to v2 format with restructured settings
  • Fixed hundreds of lint violations across test files and production code

Reviewed Changes

Copilot reviewed 47 out of 47 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Makefile Updated golangci-lint version and command path
.golangci.yml Complete migration to v2 configuration format
.github/workflows/linter.yml Updated GitHub Actions to use golangci-lint v2.5.0
Various test files Replaced require.Equal(t, "", value) with require.Empty(t, value)
Production code files Used fmt.Fprintf instead of manual string formatting, added missing default cases

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 updates golangci-lint to a newer version and applies the necessary configuration changes and code fixes to comply with the new linting rules. The changes are mostly stylistic improvements and modernizations, such as using require.Empty and require.Len in tests, and wg.Go for goroutines. I've found a few issues: a duplicated check in a test, some unreachable code, and a critical deadlock introduced in a test helper function due to incorrect usage of sync.WaitGroup. My review provides suggestions to fix these issues.

@gaby
Copy link
Member

gaby commented Oct 13, 2025

@laughing-nerd Can you rebase with main, thanks

@laughing-nerd
Copy link
Contributor Author

@gaby done 👍

@laughing-nerd
Copy link
Contributor Author

Can someone merge this PR please? Thanks

@ReneWerner87
Copy link
Member

Sure, tomorrow morning
Its the next pr on my list
Thx

@laughing-nerd
Copy link
Contributor Author

Great! Thanks!

Copy link
Member

@ReneWerner87 ReneWerner87 left a comment

Choose a reason for hiding this comment

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

@laughing-nerd can you check my last hints

@laughing-nerd
Copy link
Contributor Author

@ReneWerner87 Sure. I'll make the changes today

@ReneWerner87
Copy link
Member

@laughing-nerd ping

@laughing-nerd
Copy link
Contributor Author

Oh hey @ReneWerner87
Sorry for the delay. I'll close this today for sure

dependabot bot and others added 2 commits October 20, 2025 12:26
Bumps [github.com/shamaton/msgpack/v2](https://github.com/shamaton/msgpack) from 2.3.1 to 2.4.0.
- [Release notes](https://github.com/shamaton/msgpack/releases)
- [Commits](shamaton/msgpack@v2.3.1...v2.4.0)

---
updated-dependencies:
- dependency-name: github.com/shamaton/msgpack/v2
  dependency-version: 2.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@laughing-nerd
Copy link
Contributor Author

@ReneWerner87 I've made the changes. LMK if anything else needs to be changed

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

♻️ Duplicate comments (1)
path.go (1)

794-796: Unknown constraints now fail validation (good).

Defaulting to false for unspecified IDs is the safe behavior and aligns with custom-constraint override above.

🧹 Nitpick comments (2)
path.go (2)

187-189: Early-match is correct; consider moving before parse for perf.

You can short‑circuit before routerParserPool.Get/parseRoute to avoid extra work; functional behavior unchanged.


356-364: Guard paramEndPosition+1 to prevent future OOB panics.

Current logic is safe given how paramEndPosition is derived, but a small bound check makes it future‑proof.

Apply this diff:

-    case bytes.IndexByte(parameterDelimiterChars, pattern[paramEndPosition+1]) == -1:
+    case (paramEndPosition+1) < len(pattern) &&
+         bytes.IndexByte(parameterDelimiterChars, pattern[paramEndPosition+1]) == -1:
       paramEndPosition++
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2d22c2 and 0c8342f.

📒 Files selected for processing (3)
  • path.go (5 hunks)
  • req.go (5 hunks)
  • res.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • res.go
  • req.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Format Go code using gofumpt (Make target: make format).
Run golangci-lint for linting (Make target: make lint).
Run go vet as part of audit to catch suspicious constructs (Make target: make audit).
Optimize struct field alignment with betteralign (Make target: make betteralign).
Apply gopls modernize to update code patterns (Make target: make modernize).

Files:

  • path.go
🔇 Additional comments (2)
path.go (2)

503-506: LGTM: const-part guard with optional slash is correct.

The HasOptionalSlash branch then i > partLen || detectionPath[:i] != segment.Const fallback reads clean and is correct.


516-524: Skipping constraint checks for omitted optional params is correct.

if !segment.IsOptional || i != 0 avoids validating empty optionals (e.g., :id<int>?). Please ensure tests cover both omitted and present cases with constraints.

@ReneWerner87 ReneWerner87 merged commit 25543af into gofiber:main Oct 20, 2025
14 of 15 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in v3 Oct 20, 2025
@welcome
Copy link

welcome bot commented Oct 20, 2025

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

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.

🧹 [Maintenance]: make lint fails with go 1.25

5 participants