From 6cb4dc0ca8a6ca0fdd368da94dc40a8dfd36556f Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 16 May 2014 16:46:31 -0700 Subject: [PATCH] add comments clarifying existing behaviour of readLine --- tail.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tail.go b/tail.go index babc269..6ec57bc 100644 --- a/tail.go +++ b/tail.go @@ -169,10 +169,18 @@ func (tail *Tail) reopen() error { func (tail *Tail) readLine() ([]byte, error) { line, isPrefix, err := tail.reader.ReadLine() + if err != nil { + return nil, err + } + + // If MaxLineSize is set, we don't have to join the parts (let + // Go's reader split them). if !isPrefix || tail.MaxLineSize > 0 { return line, err } + // Join lines from next read "if the line was too long for the + // buffer". XXX: why not use ReadBytes('\n') or Scanner? buf := append([]byte(nil), line...) for isPrefix && err == nil { line, isPrefix, err = tail.reader.ReadLine()