To get the system boot time in minutes in Go, we can use the os.Stat() function to get the Sys() information of the /proc directory on Linux systems.
main.go380 chars24 linesIn this code, we first get the system Stat() information of the /proc directory. We then extract the system boot time from the Sys() information using the uptime field.
We then convert the boot time to a human-readable format using time.Unix() and time.Format(). Finally, we calculate the current system uptime in minutes by subtracting the boot time from the current time, and divide it by 60.
gistlibby LogSnag