It is quite typical to do something like the following to cancel tailing a file:
go func() {
defer t.Stop()
for {
select {
case line, ok := t.Lines:
// ...
case <-ctx.Done():
return
}
}
but then this means after the context is cancelled, there is no reader of the Tail.Lines channel and the library will block.
This change modifies the library to always select on Tail.Dying() when sending to Tail.Lines in case the user has stopped receiving and stopped the tailing.
It is quite typical to do something like the following to cancel tailing a file:
but then this means after the context is cancelled, there is no reader of the
Tail.Lines
channel and the library will block.This change modifies the library to always select on
Tail.Dying()
when sending toTail.Lines
in case the user has stopped receiving and stopped the tailing.