Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
test-unit: # <- name
strategy:
matrix:
# TODO: enable macos [macos-latest, windows-latest, ubuntu-latest]
os: [windows-latest, ubuntu-latest]
os: [macos-latest, windows-2022, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
Expand Down
27 changes: 15 additions & 12 deletions sigar_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"syscall"
"time"
"unsafe"

"golang.org/x/sys/unix"
)

func (self *LoadAverage) Get() error { //nolint:staticcheck
Expand Down Expand Up @@ -417,21 +419,22 @@ func vm_info(vmstat *C.vm_statistics_data_t) error {

// generic Sysctl buffer unmarshalling
func sysctlbyname(name string, data interface{}) (err error) {
val, err := syscall.Sysctl(name)
if err != nil {
return err
}

buf := []byte(val)

switch v := data.(type) {
case *uint64:
*v = *(*uint64)(unsafe.Pointer(&buf[0]))
return
res, err := unix.SysctlUint64(name)
if err != nil {
return err
}
*v = res
return nil
default:
val, err := syscall.Sysctl(name)
if err != nil {
return err
}
bbuf := bytes.NewBuffer([]byte(val))
return binary.Read(bbuf, binary.LittleEndian, data)
}

bbuf := bytes.NewBuffer([]byte(val))
return binary.Read(bbuf, binary.LittleEndian, data)
}

// syscall.Getfsstat() wrapper is broken, roll our own to workaround.
Expand Down