From 526bfc48e104a644647b88f9427d7471fbb691d3 Mon Sep 17 00:00:00 2001 From: grigorijski Date: Wed, 24 Jul 2024 14:40:53 +0300 Subject: [PATCH] continue sending output lines read after StopAtEOF was called --- tail.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tail.go b/tail.go index c962599..542a57b 100644 --- a/tail.go +++ b/tail.go @@ -2,11 +2,11 @@ // Copyright (c) 2015 HPE Software Inc. All rights reserved. // Copyright (c) 2013 ActiveState Software Inc. All rights reserved. -//nxadm/tail provides a Go library that emulates the features of the BSD `tail` -//program. The library comes with full support for truncation/move detection as -//it is designed to work with log rotation tools. The library works on all -//operating systems supported by Go, including POSIX systems like Linux and -//*BSD, and MS Windows. Go 1.9 is the oldest compiler release supported. +// nxadm/tail provides a Go library that emulates the features of the BSD `tail` +// program. The library comes with full support for truncation/move detection as +// it is designed to work with log rotation tools. The library works on all +// operating systems supported by Go, including POSIX systems like Linux and +// *BSD, and MS Windows. Go 1.9 is the oldest compiler release supported. package tail import ( @@ -456,6 +456,10 @@ func (tail *Tail) sendLine(line string) bool { select { case tail.Lines <- &Line{line, tail.lineNum, SeekInfo{Offset: offset}, now, nil}: case <-tail.Dying(): + if tail.Err() == errStopAtEOF { + tail.Lines <- &Line{line, tail.lineNum, SeekInfo{Offset: offset}, now, nil} + continue + } return true } }