get system cpu count in go

You can get the number of CPUs on the system using the NumCPU() function from the runtime package.

Here's an example code snippet:

main.go
package main

import (
    "fmt"
    "runtime"
)

func main() {
    numCPU := runtime.NumCPU()
    fmt.Println("CPU count:", numCPU)
}
135 chars
12 lines

This will output the number of available CPUs on the system.

related categories

gistlibby LogSnag