add comments clarifying existing behaviour of readLine
This commit is contained in:
parent
8dcd1ad3e5
commit
6cb4dc0ca8
8
tail.go
8
tail.go
|
@ -169,10 +169,18 @@ func (tail *Tail) reopen() error {
|
||||||
|
|
||||||
func (tail *Tail) readLine() ([]byte, error) {
|
func (tail *Tail) readLine() ([]byte, error) {
|
||||||
line, isPrefix, err := tail.reader.ReadLine()
|
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 {
|
if !isPrefix || tail.MaxLineSize > 0 {
|
||||||
return line, err
|
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...)
|
buf := append([]byte(nil), line...)
|
||||||
for isPrefix && err == nil {
|
for isPrefix && err == nil {
|
||||||
line, isPrefix, err = tail.reader.ReadLine()
|
line, isPrefix, err = tail.reader.ReadLine()
|
||||||
|
|
Loading…
Reference in New Issue