refactor this part of code for upcoming change
This commit is contained in:
parent
929590016a
commit
941cc3e301
11
tail.go
11
tail.go
|
@ -213,9 +213,7 @@ func (tail *Tail) tailFileSync() {
|
||||||
for {
|
for {
|
||||||
line, err := tail.readLine()
|
line, err := tail.readLine()
|
||||||
|
|
||||||
switch err {
|
if err == nil {
|
||||||
case nil:
|
|
||||||
if true {
|
|
||||||
cooloff := !tail.sendLine(line)
|
cooloff := !tail.sendLine(line)
|
||||||
if cooloff {
|
if cooloff {
|
||||||
// Wait a second before seeking till the end of
|
// Wait a second before seeking till the end of
|
||||||
|
@ -235,9 +233,7 @@ func (tail *Tail) tailFileSync() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}else if err == io.EOF {
|
||||||
case io.EOF:
|
|
||||||
// XXX: should `line` be returned at this point?
|
|
||||||
if !tail.Follow {
|
if !tail.Follow {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -251,7 +247,8 @@ func (tail *Tail) tailFileSync() {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default: // non-EOF error
|
}else {
|
||||||
|
// non-EOF error
|
||||||
tail.Killf("Error reading %s: %s", tail.Filename, err)
|
tail.Killf("Error reading %s: %s", tail.Filename, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue