Standard library / runtime
runtime.NumCPU()
Reports logical CPUs usable by the process as detected at startup; not a current utilization measurement. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func NumCPU() intReturn Value
int
Logical CPU count detected for this process at startup.
Working Example
Example Snippetgo
package main
import ( "fmt" "runtime")
func main() { fmt.Println(runtime.NumCPU() > 0) }