fix Go 1.14 build

pull/248/head
q191201771 2 years ago
parent 46c0b47911
commit 6dff63cbfd

@ -0,0 +1,19 @@
// Copyright 2022, Chef. All rights reserved.
// https://github.com/q191201771/lal
//
// Use of this source code is governed by a MIT-style license
// that can be found in the License file.
//
// Author: Chef (191201771@qq.com)
package base
import "time"
// 兼容老版本的Go不直接使用新版本Go标准库中新增的内容
// TODO(chef): [refactor] 整理到naza中 202212
func UnixMilli(t time.Time) int64 {
return t.UnixNano() / 1e6
}

@ -0,0 +1,20 @@
// Copyright 2022, Chef. All rights reserved.
// https://github.com/q191201771/lal
//
// Use of this source code is governed by a MIT-style license
// that can be found in the License file.
//
// Author: Chef (191201771@qq.com)
package base
import (
"github.com/q191201771/naza/pkg/assert"
"testing"
"time"
)
func TestUnixMilli(t *testing.T) {
n := time.Now()
assert.Equal(t, n.UnixMilli(), UnixMilli(n))
}

@ -150,7 +150,7 @@ func (d *DumpFile) pack(b []byte, typ uint32) []byte {
i += 4
bele.BePutUint32(ret[i:], uint32(len(b))) // Len
i += 4
bele.BePutUint64(ret[i:], uint64(time.Now().UnixMilli())) // Timestamp
bele.BePutUint64(ret[i:], uint64(UnixMilli(time.Now()))) // Timestamp
i += 8
copy(ret[i:], "LALD")
i += 4

Loading…
Cancel
Save