Merge pull request #38 from soolaugust/remove-deprecated

os.SEEK_* is deprecated, use io.Seek* instead
This commit is contained in:
ulricqin 2020-03-27 11:37:39 +08:00 committed by GitHub
commit 53f1c1e64d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package reader
import (
"io"
"os"
"time"
@ -25,7 +26,7 @@ func NewReader(filepath string, stream chan string) (*Reader, error) {
Close: make(chan struct{}),
}
path := GetCurrentPath(filepath)
err := r.openFile(os.SEEK_END, path) //默认打开seek_end
err := r.openFile(io.SeekEnd, path) //默认打开SeekEnd
return r, err
}
@ -122,7 +123,7 @@ func (r *Reader) check() {
return
}
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()
} else {
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)
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()
} else {
logger.Warningf("openFile err @check, err: %v\n", err.Error())