Skip to content

Commit 568a01c

Browse files
committed
Check context termination while writting into a channel.
1 parent 8826fba commit 568a01c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compsequential.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ func getChannelOrErrorSequential[T any](
219219
if !ok {
220220
break f
221221
}
222-
chanOut <- v
222+
select {
223+
case <-ctx.Done():
224+
break f
225+
case chanOut <- v:
226+
}
227+
223228
}
224229
}
225230

0 commit comments

Comments
 (0)