fixed cancel call in FindFirstAndCancel
This commit is contained in:
parent
35264315fd
commit
6fcd709cd3
2
find.go
2
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 {
|
func FindFirstAndCancel[T any](source <-chan T, cancel context.CancelFunc) *T {
|
||||||
|
defer cancel()
|
||||||
for v := range source {
|
for v := range source {
|
||||||
cancel()
|
|
||||||
return &v
|
return &v
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user