gistlib
You can get the number of CPUs on the system using the NumCPU() function from the runtime package.
NumCPU()
runtime
Here's an example code snippet:
main.gopackage main import ( "fmt" "runtime" ) func main() { numCPU := runtime.NumCPU() fmt.Println("CPU count:", numCPU) } 135 chars12 lines
package main import ( "fmt" "runtime" ) func main() { numCPU := runtime.NumCPU() fmt.Println("CPU count:", numCPU) }
This will output the number of available CPUs on the system.
gistlibby LogSnag