From 7ccd8397a1e4deffb12432ebf6324ab58989b020 Mon Sep 17 00:00:00 2001 From: funkygao Date: Fri, 11 Oct 2013 17:00:29 +0800 Subject: [PATCH] fix problem of long line EOF --- tail.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tail.go b/tail.go index fbf3129..45a7c9b 100644 --- a/tail.go +++ b/tail.go @@ -170,8 +170,17 @@ func (tail *Tail) reopen() error { } func (tail *Tail) readLine() ([]byte, error) { - line, _, err := tail.reader.ReadLine() - return line, err + line, isPrefix, err := tail.reader.ReadLine() + if !isPrefix { + return line, err + } + + buf := append([]byte(nil), line...) + for isPrefix && err == nil { + line, isPrefix, err = tail.reader.ReadLine() + buf = append(buf, line...) + } + return buf, err } func (tail *Tail) tailFileSync() {