Find out how many logical processors used by current process
NumCPU returns the number of logical CPUs usable by the current process.
Example
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println(runtime.NumCPU())
}
Most Helpful This Week
Cannot convert <type1> to <type2> error in Golang
Go program to find Name Server (NS) record of a domain
Type assertion in Go Programming Language
Illustration of the dining philosophers problem in Golang
GO Program to take user input and addition of two strings
How do you handle HTTP timeouts with an HTTP client in Go?
Database as a Service (DBaaS): Simplifying Database Management in the Cloud
How to use WaitGroup to delay execution of the main function until after all goroutines are complete.
Pass an Interface as an argument to a function in Go (Golang)
Cannot use <variable> (type <type>) as type <new-type> error in Golang