From ac52cdf9c4c08e06d784c9a8f4b7cc65b08cfd21 Mon Sep 17 00:00:00 2001 From: Ameir Abdeldayem Date: Tue, 5 Mar 2024 15:46:16 -0500 Subject: [PATCH] Update location after read When tailing without following, Tell() is not available due to the file handle already being closed. Instead, we can keep Location up to date to provide this information. --- tail.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tail.go b/tail.go index c962599..7cace59 100644 --- a/tail.go +++ b/tail.go @@ -298,10 +298,12 @@ func (tail *Tail) tailFileSync() { // do not seek in named pipes if !tail.Pipe { // grab the position in case we need to back up in the event of a half-line - if _, err := tail.Tell(); err != nil { + offset, err := tail.Tell() + if err != nil { tail.Kill(err) return } + tail.Location = &SeekInfo{Offset: offset, Whence: io.SeekStart} } line, err := tail.readLine()