fix unstable boot time because of float conversion

Signed-off-by: YangKeao <yangkeao@chunibyo.icu>
pull/1204/head
YangKeao 3 years ago
parent c6bccaff3b
commit 1b5757b7d1

@ -1,3 +1,4 @@
//go:build linux
// +build linux
package common
@ -100,8 +101,9 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
if err != nil {
return 0, err
}
t := uint64(time.Now().Unix()) - uint64(b)
return t, nil
currentTime := float64(time.Now().UnixNano()) / float64(time.Second)
t := currentTime - b
return uint64(t), nil
}
return 0, fmt.Errorf("could not find btime")

Loading…
Cancel
Save