Search code examples
gosystemcpu-cores

How to find out the number of CPUs in Go lang?


Is there a simple way to find out the number of CPU's on a local machine using Go lang?


Solution

  • http://play.golang.org/p/cuaf2ZHLIx

    package main
    
    import (  
        "fmt"
        "runtime"
    )
    
    func main() {
        fmt.Println(runtime.NumCPU())
    }