From 2bc904e34ff9917a92934d1d7e91c7e3c673a3f6 Mon Sep 17 00:00:00 2001 From: miraclesu Date: Wed, 9 Dec 2015 16:38:19 +0800 Subject: [PATCH] colse file just one time --- tail.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tail.go b/tail.go index ae5b95b..83d5bc1 100644 --- a/tail.go +++ b/tail.go @@ -153,15 +153,18 @@ func (tail *Tail) Stop() error { func (tail *Tail) close() { close(tail.Lines) + tail.colseFile() +} + +func (tail *Tail) colseFile() { if tail.file != nil { tail.file.Close() + tail.file = nil } } func (tail *Tail) reopen() error { - if tail.file != nil { - tail.file.Close() - } + tail.colseFile() for { var err error tail.file, err = OpenFile(tail.Filename)