Skip to content

Conversation

lmars
Copy link

@lmars lmars commented Oct 24, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant