mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
change function time.Duration.Milliseconds to time.Duration.Nanoseconds for compatibility of Golang version < 1.13
This commit is contained in:
@ -82,7 +82,9 @@ func (p *Pool) Put(value interface{}) error {
|
||||
if p.TTL == 0 {
|
||||
item.expire = 0
|
||||
} else {
|
||||
item.expire = gtime.TimestampMilli() + p.TTL.Milliseconds()
|
||||
// As for Golang version <= 1.13, there's no method Milliseconds for time.Duration.
|
||||
// So we need calculate the milliseconds using its nanoseconds value.
|
||||
item.expire = gtime.TimestampMilli() + p.TTL.Nanoseconds()/1000000
|
||||
}
|
||||
p.list.PushBack(item)
|
||||
return nil
|
||||
|
||||
@ -141,7 +141,9 @@ func (l *Logger) rotateChecks() {
|
||||
// Expiration checks.
|
||||
if l.config.RotateExpire > 0 {
|
||||
nowTimestampMilli := gtime.TimestampMilli()
|
||||
expireMillisecond := l.config.RotateExpire.Milliseconds()
|
||||
// As for Golang version <= 1.13, there's no method Milliseconds for time.Duration.
|
||||
// So we need calculate the milliseconds using its nanoseconds value.
|
||||
expireMillisecond := l.config.RotateExpire.Nanoseconds() / 1000000
|
||||
for _, array := range backupFilesMap {
|
||||
array.Iterator(func(_ int, v interface{}) bool {
|
||||
path := v.(string)
|
||||
|
||||
Reference in New Issue
Block a user