Merge pull request #1204 from YangKeao/fix-unstable-boottime

fix unstable boot time because of float conversion
pull/1221/head
shirou 3 years ago committed by GitHub
commit b4808b3e94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save