On Wed, Apr 12, 2023 at 7:44 AM burak serdar <bser...@computer.org> wrote: > > There are ways to reduce the boilerplate code. For instance: > > func LongTask(ctx context.Context) { > canceled:=func() bool { > select { > case <-ctx.Done(): return true > default: > } > return false > }
It turns out that you can make that shorter still: canceled := func() bool { return ctx.Err() != nil } Ian -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWONyMkYXXhVOPoRSXE%2BF-JcvN5ET5RrRckrDMoo7mfFA%40mail.gmail.com.