Use for range over integers#2305
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kolyshkin The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
mtrmac
left a comment
There was a problem hiding this comment.
LGTM WRT correctness of the changes.
As for the style … Aesthetically, I’m not personally much of a fan.
for _ := range 10 to express “10 times”, sure. The full for i := range 10, has, to my taste, a bit too much implicit and hidden about the interval this operates over.
Ultimately, I think it might be easier to given in than to continue fight default linters’ settings over this. That is, alone, a good enough reason to merge this.
I’ll, at least, let someone else chime in, on the small chance that my dislike of this syntax were universally and strongly shared.
By the way, this can (and should) be shortened to
I'm with you on that. To me, I guess though this is mostly because I'm so much used to reading (and writing) in the (old/classical) way, thus I'm just biased. Over time, as more and more new style code will appear, the perception should change.
One other reason is, we all have to adopt to this new style (as this is now standard), and this PR is an attempt to speed up this process.
Would also like to hear more opinions on this one. |
This form is available since Go 1.22 (see https://tip.golang.org/ref/spec#For_range) and will probably be seen more and more in the new code. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
|
I am fine with the new style. |
This form is available since Go 1.22 (see https://tip.golang.org/ref/spec#For_range) and will probably be seen more and more in the new code.