fix problem of long line EOF

This commit is contained in:
funkygao 2013-10-11 17:00:29 +08:00 committed by YAMASAKI Masahide
parent 24d682e8af
commit 7ccd8397a1
1 changed files with 11 additions and 2 deletions

11
tail.go
View File

@ -170,10 +170,19 @@ func (tail *Tail) reopen() error {
} }
func (tail *Tail) readLine() ([]byte, error) { func (tail *Tail) readLine() ([]byte, error) {
line, _, err := tail.reader.ReadLine() line, isPrefix, err := tail.reader.ReadLine()
if !isPrefix {
return line, err 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() { func (tail *Tail) tailFileSync() {
defer tail.Done() defer tail.Done()
defer tail.close() defer tail.close()