Use range over int after 1.22 upgrade #113

Merged
fyrchik merged 1 commit from elebedeva/frostfs-api-go:feat/range-over-int-go1.22 into master 2024-11-02 14:21:46 +00:00
Member

Relates to TrueCloudLab/frostfs-node#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 {
    ...
}

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

Relates to TrueCloudLab/frostfs-node#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 { ... } ``` Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
elebedeva added the
refactoring
go
internal
labels 2024-09-04 13:55:05 +00:00
elebedeva added 2 commits 2024-09-04 13:55:09 +00:00
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
[#113] go.mod: Use range over int
All checks were successful
DCO action / DCO (pull_request) Successful in 41s
Tests and linters / Lint (pull_request) Successful in 1m11s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m11s
Tests and linters / Tests (1.23) (pull_request) Successful in 1m10s
Tests and linters / Tests with -race (pull_request) Successful in 1m23s
bd588fa2e5
Since Go 1.22 a `for` statement with a `range` clause is able
to iterate through integer values from zero to an upper limit.

gopatch 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 {
    ...
}

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
elebedeva requested review from storage-core-committers 2024-09-04 13:55:30 +00:00
elebedeva requested review from storage-core-developers 2024-09-04 13:55:31 +00:00
acid-ant approved these changes 2024-09-04 14:12:47 +00:00
achuprov approved these changes 2024-09-04 14:12:58 +00:00
dstepanov-yadro approved these changes 2024-09-04 14:23:47 +00:00
fyrchik approved these changes 2024-09-06 12:43:56 +00:00
fyrchik merged commit bd588fa2e5 into master 2024-09-06 12:44:02 +00:00
fyrchik referenced this pull request from a commit 2024-09-06 12:44:03 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
5 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-api-go#113
No description provided.