From bf7447d32a77eab18b240df62a7985c045d2f0c8 Mon Sep 17 00:00:00 2001 From: soolaugust Date: Fri, 27 Mar 2020 09:14:20 +0800 Subject: [PATCH] os.SEEK_* is deprecated, use io.Seek* instead --- src/modules/collector/log/reader/reader.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/collector/log/reader/reader.go b/src/modules/collector/log/reader/reader.go index 8c3b68de..2456a250 100644 --- a/src/modules/collector/log/reader/reader.go +++ b/src/modules/collector/log/reader/reader.go @@ -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())