Skip to content

Conversation

wanghaolong613
Copy link
Contributor

optimize: for loop can be modernized using range over int

@wanghaolong613 wanghaolong613 reopened this Oct 9, 2025
@appleboy appleboy added this to the v1.12 milestone Oct 9, 2025
@appleboy appleboy requested a review from Copilot October 9, 2025 03:32
Copy link
Contributor

@Copilot 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 modernizes Go for loops by replacing traditional for i := 0; i < n; i++ patterns with the newer for i := range n syntax introduced in Go 1.22, improving code readability and consistency.

  • Modernizes for loops across test files and production code using range over integers
  • Updates benchmark functions to use the cleaner range syntax
  • Maintains identical functionality while improving code clarity

Reviewed Changes

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

Show a summary per file
File Description
utils_test.go Updates benchmark loop to use range over int
utils.go Modernizes ASCII checking loop to use range syntax
path_test.go Updates benchmark loops to use range over int
internal/bytesconv/bytesconv_test.go Modernizes test and benchmark loops with range syntax
gin_integration_test.go Updates concurrent test loop to use range over int
context_test.go Modernizes test data generation and benchmark loops
binding/form_mapping_benchmark_test.go Updates benchmark loops to use range syntax
binding/form_mapping.go Modernizes struct field iteration loop
binding/default_validator_benchmark_test.go Updates benchmark loop to use range syntax
binding/default_validator.go Modernizes error handling and validation loops
benchmarks_test.go Updates benchmark loop to use range over int

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.81%. Comparing base (3dc1cd6) to head (5cc78bb).
⚠️ Report is 190 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4392      +/-   ##
==========================================
- Coverage   99.21%   98.81%   -0.40%     
==========================================
  Files          42       44       +2     
  Lines        3182     3463     +281     
==========================================
+ Hits         3157     3422     +265     
- Misses         17       30      +13     
- Partials        8       11       +3     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 98.80% <100.00%> (?)
-tags go_json 98.74% <100.00%> (?)
-tags nomsgpack 98.80% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.24 98.81% <100.00%> (?)
go-1.25 98.81% <100.00%> (?)
macos-latest 98.81% <100.00%> (-0.40%) ⬇️
ubuntu-latest 98.81% <100.00%> (-0.40%) ⬇️

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.

@wanghaolong613 wanghaolong613 changed the title fix: for loop can be modernized using range over int refactor: for loop can be modernized using range over int Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants