From 438814e175a1dd81e50ff77c6b9048a9c19c7b0e Mon Sep 17 00:00:00 2001 From: kruskall <99559985+kruskall@users.noreply.github.com> Date: Tue, 16 Aug 2022 03:56:52 +0200 Subject: [PATCH] refactor: replace GetTickCount64 with DurationSinceBoot from stdlib (#128) DurationSinceBoot was added to the stdlib. See https://github.com/golang/sys/commit/5da285871e9c6a1c3acade75bea3282d33f55ebd --- providers/windows/boottime_windows.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/providers/windows/boottime_windows.go b/providers/windows/boottime_windows.go index bf80c608..e04d9a40 100644 --- a/providers/windows/boottime_windows.go +++ b/providers/windows/boottime_windows.go @@ -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