Re: [go-nuts] Looping and tail-end code

2022-01-12 Thread David Finkel
On Wed, Jan 12, 2022 at 5:02 AM Tobias Klausmann wrote > So what is the *idiomatic* way of being able to use `continue` (or > something like it), yet have "always do this" code at the end of the > loop? As I understand it, `defer` only works for ends of functions, not > ends of blocks, and label

Re: [go-nuts] Looping and tail-end code

2022-01-12 Thread Tobias Klausmann
Hi! On Wed, 12 Jan 2022, Rob Pike wrote: > What's wrong with >for ;; time.Sleep(delay) { ... } > ? > > This technique is as old as the hills. Or at least as old as C for loops. Never been a C guy :) Thanks, that works perfectly! Best, Tobias -- You received this message because you are s

Re: [go-nuts] Looping and tail-end code

2022-01-12 Thread Rob Pike
What's wrong with for ;; time.Sleep(delay) { ... } ? This technique is as old as the hills. Or at least as old as C for loops. -rob On Wed, Jan 12, 2022 at 9:02 PM Tobias Klausmann wrote: > > Hi! > > Often with tools that poll something, you get code of this form: > > ``` > for { >

[go-nuts] Looping and tail-end code

2022-01-12 Thread Tobias Klausmann
Hi! Often with tools that poll something, you get code of this form: ``` for { r, err := doSomeCall() if err != nil { log.Printf("Some error:", err) continue } s, err := doSomeOtherCall(r) if err != nil { log.Printf(