mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-29 13:49:21 +08:00
[host] go-fmt and propagate context on Windows in Info()
This commit is contained in:
parent
d80c43f9c9
commit
98c779765f
@ -77,7 +77,7 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boot, err := BootTime()
|
boot, err := BootTimeWithContext(ctx)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ret.BootTime = boot
|
ret.BootTime = boot
|
||||||
ret.Uptime, _ = Uptime()
|
ret.Uptime, _ = Uptime()
|
||||||
@ -87,12 +87,12 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) {
|
|||||||
{
|
{
|
||||||
hostID, err := getMachineGuid()
|
hostID, err := getMachineGuid()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ret.HostID = strings.ToLower(hostID)
|
ret.HostID = hostID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
procs, err := process.Pids()
|
procs, err := process.PidsWithContext(ctx)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ret.Procs = uint64(len(procs))
|
ret.Procs = uint64(len(procs))
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ func getMachineGuid() (string, error) {
|
|||||||
return "", fmt.Errorf("HostID incorrect: %q\n", hostID)
|
return "", fmt.Errorf("HostID incorrect: %q\n", hostID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return hostID, nil
|
return strings.ToLower(hostID), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Uptime() (uint64, error) {
|
func Uptime() (uint64, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user