原博客地址版权声明: https://blog.csdn.net/qq_23179075/article/details/83651373
Go 获取电脑 CPUID
func main() {
fmt.Println(getCpuId())
}
func getCpuId() string {
cmd := exec.Command("wmic", "cpu", "get", "ProcessorID")
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(err)
}
fmt.Println(string(out))
str := string(out)
reg := regexp.MustCompile("\\s+")
str = reg.ReplaceAllString(str, "")
return str[11:]
}
|
请发表评论