enter image description here
上面的图像详细说明了从Windows systeminfo命令输出中获取的信息。我需要Golang库中的系统模型。
最佳答案
在Windows中,您可以调用systeminfo
命令,然后使用正则表达式对其进行过滤。
func main() {
c := exec.Command(`systeminfo`)
output,err:= c.Output()
if err != nil {
panic(err)
}
s := string(output)
var re = regexp.MustCompile(`(?:System Model: +)(.+)`)
result:=re.FindStringSubmatch(s)
if len(result)>0{
println(result[1])
}
}
Playground link
关于go - 如何使用GoLang Library获取系统模型。请引用我的图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58968852/