mem: code cleanup

This commit is contained in:
Justin Yang 2023-09-10 02:31:10 +08:00
parent e82d2e4ca8
commit 6100e33de2
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
//go:build !darwin && !linux && !freebsd && !openbsd && !solaris && !windows && !plan9 && !aix //go:build !darwin && !linux && !freebsd && !openbsd && !solaris && !windows && !plan9 && !aix && !netbsd
// +build !darwin,!linux,!freebsd,!openbsd,!solaris,!windows,!plan9,!aix // +build !darwin,!linux,!freebsd,!openbsd,!solaris,!windows,!plan9,!aix,!netbsd
package mem package mem

View File

@ -4,13 +4,10 @@
package mem package mem
import ( import (
"bytes"
"context" "context"
"encoding/binary"
"errors" "errors"
"fmt" "fmt"
"github.com/shirou/gopsutil/v3/internal/common"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -51,7 +48,10 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0 ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0
// Get buffers from vm.bufmem sysctl // Get buffers from vm.bufmem sysctl
ret.Buffers = unix.SysctlUint64("vm.bufmem") ret.Buffers, err = unix.SysctlUint64("vm.bufmem")
if err != nil {
return nil, err
}
return ret, nil return ret, nil
} }