github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/pkg/sysinfo/numcpu.go (about) 1 package sysinfo // import "github.com/Prakhar-Agarwal-byte/moby/pkg/sysinfo" 2 3 import ( 4 "runtime" 5 ) 6 7 // NumCPU returns the number of CPUs. On Linux and Windows, it returns 8 // the number of CPUs which are currently online. On other platforms, 9 // it's the equivalent of [runtime.NumCPU]. 10 func NumCPU() int { 11 if ncpu := numCPU(); ncpu > 0 { 12 return ncpu 13 } 14 return runtime.NumCPU() 15 }