Use range over int after 1.22 upgrade #265

Merged
fyrchik merged 1 commit from elebedeva/frostfs-sdk-go:feat/range-over-int-go1.22 into master 2024-09-05 13:07:13 +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:59:51 +00:00
elebedeva added 1 commit 2024-09-04 13:59:56 +00:00
[#265] go.mod: Use range over int
All checks were successful
DCO / DCO (pull_request) Successful in 47s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m7s
Tests and linters / Tests (1.23) (pull_request) Successful in 1m7s
Tests and linters / Lint (pull_request) Successful in 1m42s
46ee543899
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>
acid-ant approved these changes 2024-09-04 14:14:16 +00:00
fyrchik approved these changes 2024-09-05 13:07:09 +00:00
fyrchik merged commit 46ee543899 into master 2024-09-05 13:07:13 +00:00
fyrchik referenced this pull request from a commit 2024-09-05 13:07:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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-sdk-go#265
No description provided.