Skip to content

Commit

Permalink
refactor: replace GetTickCount64 with DurationSinceBoot from stdlib (#…
Browse files Browse the repository at this point in the history
…128)

DurationSinceBoot was added to the stdlib.

See golang/sys@5da2858
  • Loading branch information
kruskall authored Aug 16, 2022
1 parent 7b4816e commit 438814e
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions providers/windows/boottime_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@
package windows

import (
"fmt"
"time"

windows "github.com/elastic/go-windows"
"golang.org/x/sys/windows"
)

func BootTime() (time.Time, error) {
msSinceBoot, err := windows.GetTickCount64()
if err != nil {
return time.Time{}, fmt.Errorf("failed to get boot time: %w", err)
}

bootTime := time.Now().Add(-1 * time.Duration(msSinceBoot) * time.Millisecond)
bootTime := time.Now().Add(-1 * windows.DurationSinceBoot())

// According to GetTickCount64, the resolution of the value is limited to
// the resolution of the system timer, which is typically in the range of
Expand Down

0 comments on commit 438814e

Please sign in to comment.