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

1

67

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

Auger answered 6/6, 2014 at 3:23 Comment(1)
possible duplicate of Golang: how to verify number of processors on which a Go program is runningReverie
L
106

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

package main

import (  
    "fmt"
    "runtime"
)

func main() {
    fmt.Println(runtime.NumCPU())
}
Limassol answered 6/6, 2014 at 3:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.