60

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

Kirill Fuchs
  • 13,446
  • 4
  • 42
  • 72
  • 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

96

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

package main

import (  
    "fmt"
    "runtime"
)

func main() {
    fmt.Println(runtime.NumCPU())
}
Eve Freeman
  • 32,467
  • 4
  • 86
  • 101