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

13
tail.go
View File

@ -170,8 +170,17 @@ 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()
return line, err 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() { func (tail *Tail) tailFileSync() {