From b62e1af469afce971422eabf6c5e17edf94e2f1a Mon Sep 17 00:00:00 2001 From: Joris Baum Date: Fri, 26 Sep 2025 16:03:28 +0200 Subject: [PATCH 1/3] Fix checkptr in Mem.Get() on darwin Lets the tests run through on MacOS ARM by properly using Sysctl. Credit goes to https://github.com/elastic/gosigar/pull/178/commits/2c630396f8cd8c5fa98b81dee06615e88e5f86f9 --- sigar_darwin.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/sigar_darwin.go b/sigar_darwin.go index 90be0f227..d8c7d34d1 100644 --- a/sigar_darwin.go +++ b/sigar_darwin.go @@ -23,6 +23,8 @@ import ( "syscall" "time" "unsafe" + + "golang.org/x/sys/unix" ) func (self *LoadAverage) Get() error { //nolint:staticcheck @@ -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. From db05e6756bb6593e6e7451eedc8dafb5a15c93f6 Mon Sep 17 00:00:00 2001 From: Joris Baum Date: Tue, 30 Sep 2025 09:30:49 +0200 Subject: [PATCH 2/3] Enable macos-latest in the test workflow --- .github/workflows/go.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 42c735680..5d2075576 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -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-latest, ubuntu-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v5 From b30787b1b7783006a68dc5ac238d14f2accc33be Mon Sep 17 00:00:00 2001 From: Joris Baum Date: Wed, 15 Oct 2025 17:03:58 +0200 Subject: [PATCH 3/3] Pin windows-specific GH workflow to version 2022 ...until -latest is supported again. --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5d2075576..e99161fb8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -17,7 +17,7 @@ jobs: test-unit: # <- name strategy: matrix: - os: [macos-latest, windows-latest, ubuntu-latest] + os: [macos-latest, windows-2022, ubuntu-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v5