39

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

Kirill Fuchs
  • 12,706
  • 3
  • 36
  • 70
  • possible duplicate of [Golang: how to verify number of processors on which a Go program is running](http://stackoverflow.com/questions/13234749/golang-how-to-verify-number-of-processors-on-which-a-go-program-is-running) – squiguy Jun 06 '14 at 03:25

1 Answers1

62

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

package main

import (  
    "fmt"
    "runtime"
)

func main() {
    fmt.Println(runtime.NumCPU())
}
Eve Freeman
  • 30,388
  • 2
  • 79
  • 95