Merge pull request #38 from soolaugust/remove-deprecated
os.SEEK_* is deprecated, use io.Seek* instead
This commit is contained in:
commit
53f1c1e64d
|
@ -1,6 +1,7 @@
|
||||||
package reader
|
package reader
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ func NewReader(filepath string, stream chan string) (*Reader, error) {
|
||||||
Close: make(chan struct{}),
|
Close: make(chan struct{}),
|
||||||
}
|
}
|
||||||
path := GetCurrentPath(filepath)
|
path := GetCurrentPath(filepath)
|
||||||
err := r.openFile(os.SEEK_END, path) //默认打开seek_end
|
err := r.openFile(io.SeekEnd, path) //默认打开SeekEnd
|
||||||
|
|
||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
|
@ -122,7 +123,7 @@ func (r *Reader) check() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
r.t.StopAtEOF()
|
r.t.StopAtEOF()
|
||||||
if err := r.openFile(os.SEEK_SET, nextpath); err == nil { //从文件开始打开
|
if err := r.openFile(io.SeekStart, nextpath); err == nil { //从文件开始打开
|
||||||
go r.StartRead()
|
go r.StartRead()
|
||||||
} else {
|
} else {
|
||||||
logger.Warningf("openFile err @check, err: %v\n", err.Error())
|
logger.Warningf("openFile err @check, err: %v\n", err.Error())
|
||||||
|
@ -143,7 +144,7 @@ func (r *Reader) check() {
|
||||||
logger.Warningf("inode changed, reopen file %v\n", r.CurrentPath)
|
logger.Warningf("inode changed, reopen file %v\n", r.CurrentPath)
|
||||||
|
|
||||||
r.t.StopAtEOF()
|
r.t.StopAtEOF()
|
||||||
if err := r.openFile(os.SEEK_SET, nextpath); err == nil { //从文件开始打开
|
if err := r.openFile(io.SeekStart, nextpath); err == nil { //从文件开始打开
|
||||||
go r.StartRead()
|
go r.StartRead()
|
||||||
} else {
|
} else {
|
||||||
logger.Warningf("openFile err @check, err: %v\n", err.Error())
|
logger.Warningf("openFile err @check, err: %v\n", err.Error())
|
||||||
|
|
Loading…
Reference in New Issue