fixed cancel call in FindFirstAndCancel
This commit is contained in:
parent
35264315fd
commit
22cf4c9499
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 {
|
||||
defer cancel()
|
||||
for v := range source {
|
||||
cancel()
|
||||
return &v
|
||||
}
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user