From ae251eb6a25f34d7d5f1aa53d7940374f1e4898a Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Tue, 15 Nov 2016 00:53:20 +0900 Subject: [PATCH] cpu[darwin]: fix Go arrays panic in cgo #279 --- cpu/cpu_darwin_cgo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/cpu_darwin_cgo.go b/cpu/cpu_darwin_cgo.go index 6b813d7..180e0af 100644 --- a/cpu/cpu_darwin_cgo.go +++ b/cpu/cpu_darwin_cgo.go @@ -57,7 +57,7 @@ func perCPUTimes() ([]TimesStat, error) { // copy the cpuload array to a []byte buffer // where we can binary.Read the data size := int(ncpu) * binary.Size(cpu_ticks) - buf := C.GoBytes(unsafe.Pointer(cpuload), C.int(size)) + buf := (*[1 << 30]byte)(unsafe.Pointer(cpuload))[:size:size] bbuf := bytes.NewBuffer(buf)