The question is about the usage once
variable in the following snippet extracted from the pipe.go
of the standard go library
for once := true; once || len(b) > 0; once = false {
select {
case p.wrCh <- b:
nw := <-p.rdCh
b = b[nw:]
n += nw
case <-p.done:
return n, p.writeCloseError()
}
}
My understanding is that, the loop won't terminate as long as len(b) > 0
and the loop would be executed at least once.
So why not just write
for len(b) > 0 { ... }