Re: [go-nuts] evaluation of range expression in for-range loop

2024-02-05 Thread Tamás Gulácsi
Yes. If you manipulate the meaning of the index (i) or the length of the slice, then do it explicitly: for i := 0; i < len(a); i++ { if a[i] == 0 { //delete a[i]=a[0] a = a[1:] i-- } } For other methods, see https://go.dev/wiki/SliceTricks#filtering-without-allocating Shivansh

[go-nuts] Re: go mod download fails on docker for 1.20 (but not for 1.18)

2024-02-05 Thread 'Bryan C. Mills' via golang-nuts
In https://go.dev/issue/52545 we saw failures in the cmd/go tests on Google Cloud VMs due to a combination of a small number of available NAT ports and port exhaustion from TIME_WAIT connections, but the failure mode there was different (timed-out git commands rather than "cannot assign requeste

Re: [go-nuts] evaluation of range expression in for-range loop

2024-02-05 Thread Shivansh Rustagi
Hi Guys, I had a question regarding: > On the other hand, if you have `for i, v := range a {` then the > expression *is* evaluated before the start of the loop. I have a code (https://goplay.tools/snippet/dMwD0_rEhkB) where I am ranging over a slice, and updating (removing the zeroth element for