On Monday, 19 December 2022 at 10:01:41 UTC Torsten Bronger wrote: > I would additionally check for ctx.Err() != nil somewhere in the > loop. Or is there a reason why this is not necessary? >
See https://pkg.go.dev/context#Context // If Done is not yet closed, Err returns nil. // If Done is closed, Err returns a non-nil error explaining why: // Canceled if the context was canceled // or DeadlineExceeded if the context's deadline passed. // After Err returns a non-nil error, successive calls to Err return the same error. Err() error Therefore, it's impossible for ctx.Err() != nil unless ctx.Done() is closed - and the loop is already checking for this. -- 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/eb1149f1-cf5f-4b3f-90a1-d183d212784cn%40googlegroups.com.