Use range over int after 1.22 upgrade #1345

Merged
fyrchik merged 1 commit from elebedeva/frostfs-node:feat/range-over-int-go1.22 into master 2024-09-03 11:26:44 +00:00
Member

Close #1317

Since Go 1.22 a for statement with a range clause is able to iterate through integer values from zero to an upper limit.

Files were changed via gopatch with a script:

@@
var i, e expression
@@
-for i := 0; i <= e - 1; i++ {
+for i := range e {
    ...
}

@@
var i, e expression
@@
-for i := 0; i <= e; i++ {
+for i := range e + 1 {
    ...
}

@@
var i, e expression
@@
-for i := 0; i < e; i++ {
+for i := range e {
    ...
}

Unused identifiers were removed manually. 🥲

Signed-off-by: Ekaterina Lebedeva ekaterina.lebedeva@yadro.com

Close #1317 Since Go 1.22 a `for` statement with a `range` clause is able to iterate through integer values from zero to an upper limit. Files were changed via [`gopatch`](https://github.com/uber-go/gopatch) with a script: ``` @@ var i, e expression @@ -for i := 0; i <= e - 1; i++ { +for i := range e { ... } @@ var i, e expression @@ -for i := 0; i <= e; i++ { +for i := range e + 1 { ... } @@ var i, e expression @@ -for i := 0; i < e; i++ { +for i := range e { ... } ``` Unused identifiers were removed manually. 🥲 Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
elebedeva added the
refactoring
go
internal
labels 2024-08-30 16:39:59 +00:00
elebedeva added 1 commit 2024-08-30 16:40:05 +00:00
[#1317] go.mod: Use range over int
All checks were successful
DCO action / DCO (pull_request) Successful in 1m49s
Tests and linters / Run gofumpt (pull_request) Successful in 2m15s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m41s
Build / Build Components (1.22) (pull_request) Successful in 2m49s
Build / Build Components (1.23) (pull_request) Successful in 2m48s
Vulncheck / Vulncheck (pull_request) Successful in 2m30s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m45s
Tests and linters / Staticcheck (pull_request) Successful in 3m49s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m52s
Tests and linters / gopls check (pull_request) Successful in 4m25s
Tests and linters / Lint (pull_request) Successful in 4m44s
Tests and linters / Tests with -race (pull_request) Successful in 4m39s
1a17a5594c
Since Go 1.22 a "for" statement with a "range" clause is able
to iterate through integer values from zero to an upper limit.

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
elebedeva requested review from storage-core-committers 2024-08-30 16:45:55 +00:00
elebedeva requested review from storage-core-developers 2024-08-30 16:45:55 +00:00
Owner

identifier is an expression, so you can always use expression and remove patches with x identifier.
Should lead to the same result.

`identifier` _is_ an `expression`, so you can always use `expression` and remove patches with `x identifier`. Should lead to the same result.
Owner

Also, please, attach the patch to the commit message.

Also, please, attach the patch to the commit message.
aarifullin approved these changes 2024-09-02 10:20:57 +00:00
aarifullin left a comment
Member

Good!

Good!
achuprov approved these changes 2024-09-02 10:33:09 +00:00
elebedeva force-pushed feat/range-over-int-go1.22 from 1a17a5594c to df05920c8e 2024-09-03 09:58:04 +00:00 Compare
elebedeva force-pushed feat/range-over-int-go1.22 from df05920c8e to a685fcdc96 2024-09-03 10:02:19 +00:00 Compare
fyrchik merged commit a685fcdc96 into master 2024-09-03 11:26:44 +00:00
elebedeva deleted branch feat/range-over-int-go1.22 2024-09-04 12:49:45 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-committers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1345
No description provided.