diff --git a/mem/mem_fallback.go b/mem/mem_fallback.go index 0b6c528..697fd87 100644 --- a/mem/mem_fallback.go +++ b/mem/mem_fallback.go @@ -1,5 +1,5 @@ -//go:build !darwin && !linux && !freebsd && !openbsd && !solaris && !windows && !plan9 && !aix -// +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,!netbsd package mem diff --git a/mem/mem_netbsd.go b/mem/mem_netbsd.go index fb6fafe..6e2be3f 100644 --- a/mem/mem_netbsd.go +++ b/mem/mem_netbsd.go @@ -4,13 +4,10 @@ package mem import ( - "bytes" "context" - "encoding/binary" "errors" "fmt" - "github.com/shirou/gopsutil/v3/internal/common" "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 // 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 }