File: uptime_windows.go

package info (click to toggle)
golang-github-juju-utils 0.0~git20200923.4646bfe-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,324 kB
  • sloc: makefile: 37
file content (20 lines) | stat: -rw-r--r-- 498 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2014 Cloudbase Solutions SRL
// Copyright 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.

package uptime

import (
	"fmt"
)

//sys getTickCount64() (uptime uint64, err error) =  GetTickCount64

// Uptime returns the number of seconds since the system has booted
func Uptime() (int64, error) {
	uptime, err := getTickCount64()
	if err != nil {
		return 0, fmt.Errorf("Failed to get uptime. Error number: %v", err)
	}
	return int64(uptime) / 1000, nil
}