diff --git a/core/logx/rotatelogger.go b/core/logx/rotatelogger.go index 39798f5167f2..5944d59358e3 100644 --- a/core/logx/rotatelogger.go +++ b/core/logx/rotatelogger.go @@ -19,14 +19,14 @@ import ( ) const ( - rfc3339DateFormat = time.RFC3339 - dateFormat = "2006-01-02" - hoursPerDay = 24 - bufferSize = 100 - defaultDirMode = 0o755 - defaultFileMode = 0o600 - gzipExt = ".gz" - megaBytes = 1 << 20 + dateFormat = "2006-01-02" + fileTimeFormat = time.RFC3339 + hoursPerDay = 24 + bufferSize = 100 + defaultDirMode = 0o755 + defaultFileMode = 0o600 + gzipExt = ".gz" + megaBytes = 1 << 20 ) // ErrLogFileClosed is an error that indicates the log file is already closed. @@ -195,7 +195,7 @@ func (r *SizeLimitRotateRule) OutdatedFiles() []string { // test if any too old backups if r.days > 0 { - boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(rfc3339DateFormat) + boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(fileTimeFormat) boundaryFile := filepath.Join(dir, fmt.Sprintf("%s%s%s%s", prefix, r.delimiter, boundary, ext)) if r.gzip { boundaryFile += gzipExt @@ -413,7 +413,7 @@ func getNowDate() string { } func getNowDateInRFC3339Format() string { - return time.Now().Format(rfc3339DateFormat) + return time.Now().Format(fileTimeFormat) } func gzipFile(file string) error { diff --git a/core/logx/rotatelogger_test.go b/core/logx/rotatelogger_test.go index 75865c098cf8..51cc888de3cf 100644 --- a/core/logx/rotatelogger_test.go +++ b/core/logx/rotatelogger_test.go @@ -51,7 +51,7 @@ func TestSizeLimitRotateRuleOutdatedFiles(t *testing.T) { func TestSizeLimitRotateRuleShallRotate(t *testing.T) { var rule SizeLimitRotateRule - rule.rotatedTime = time.Now().Add(time.Hour * 24).Format(rfc3339DateFormat) + rule.rotatedTime = time.Now().Add(time.Hour * 24).Format(fileTimeFormat) rule.maxSize = 0 assert.False(t, rule.ShallRotate(0)) rule.maxSize = 100 diff --git a/zrpc/internal/rpcpubserver.go b/zrpc/internal/rpcpubserver.go index de720c95d351..5a2a5136d54f 100644 --- a/zrpc/internal/rpcpubserver.go +++ b/zrpc/internal/rpcpubserver.go @@ -41,12 +41,12 @@ type keepAliveServer struct { Server } -func (ags keepAliveServer) Start(fn RegisterFn) error { - if err := ags.registerEtcd(); err != nil { +func (s keepAliveServer) Start(fn RegisterFn) error { + if err := s.registerEtcd(); err != nil { return err } - return ags.Server.Start(fn) + return s.Server.Start(fn) } func figureOutListenOn(listenOn string) string {