From 6fcd709cd378bdd3feb0c679ee2483905d7bb7f3 Mon Sep 17 00:00:00 2001 From: milarin Date: Wed, 10 Jan 2024 22:00:20 +0100 Subject: [PATCH] fixed cancel call in FindFirstAndCancel --- find.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/find.go b/find.go index e516949..006fdcc 100644 --- a/find.go +++ b/find.go @@ -10,8 +10,8 @@ func FindFirst[T any](source <-chan T) *T { } func FindFirstAndCancel[T any](source <-chan T, cancel context.CancelFunc) *T { + defer cancel() for v := range source { - cancel() return &v } return nil