To get the system boot time in milliseconds using Go on a Windows system, you can use the GetTickCount64
function from the Windows API through the syscall
package. Here's an example:
main.go356 chars16 lines
Here, we first call GetTickCount64
to get the system uptime in milliseconds. We then subtract this from the current time using time.Now()
and time.Duration(tickCount) * time.Millisecond
to get the system boot time. Finally, we convert the boot time to milliseconds, print it out along with a message.
Note that this method only works on a Windows system, and requires you to call the syscall
package.
gistlibby LogSnag