I just tried it here with go1.26.0. "go fix" treats both examples as I
would expect. ie. the first example is converted and the second example is
not.
first example:
for row := 0; row < N; row++ {
for col := 0; col < N; col++ {
for qrow := 0; qrow < N; qrow++ {
for qcol := 0; qcol < N; qcol++ {
}
}
}
}
is converted to:
for range N {
for range N {
for range N {
for range N {
}
}
}
}
second example:
for row := 1; row < N; row++ {
for col := 2; col < N; col++ {
for qrow := 3; qrow < N; qrow++ {
for qcol := 4; qcol < N; qcol++ {
}
}
}
}
is not converted.
On Monday, 16 February 2026 at 16:58:03 UTC Reinhard Wobst wrote:
> P.S.: I used go 1.26.0
>
> Reinhard Wobst schrieb am Montag, 16. Februar 2026 um 17:54:56 UTC+1:
>
>> To a program with
>>
>> for row := 0; row < N; row++ {
>> for col := 0; col < N; col++ {
>> for qrow := 0; qrow < N; qrow++ {
>> for qcol := 0; qcol < N; qcol++ {
>>
>> I applied "go fix" and correctly got
>>
>> for row := range N {
>> for col := range N {
>> for qrow := range N {
>> for qcol := range N {
>>
>> Very nice. But when I modified it to
>>
>> for row := 1; row < N; row++ {
>> for col := 2; col < N; col++ {
>> for qrow := 3; qrow < N; qrow++ {
>> for qcol := 4; qcol < N; qcol++ {
>>
>> I got the same output what is obviously wrong.
>> Did I overlook something trivial?
>>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/golang-nuts/83d768f6-0927-4e73-ae74-97fed9e0ab82n%40googlegroups.com.