go设置使用多少个cpu

package main

import (
    "fmt"
    "runtime"
)

func main() {
    n := runtime.NumCPU()
    fmt.Print(n)
    runtime.GOMAXPROCS(n - 1) //设置cpu运行的数目
}




原文地址:https://www.cnblogs.com/hualou/p/12069983.html