go - 如何使用GoLang Library获取系统模型。请引用我的图片

标签 go

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/

相关文章:

戈朗 : strange issue with coroutines and channels

google-app-engine - App Engine 转到 : How to kill a running goroutine

json - 根据 JSON 模式验证结构

Go 中的协程和 channel

http - Golang路由前修改URL路径等HTTP请求参数

go - Golang追加更改追加参数

go - 为什么 map 和类型断言可以返回 1 或 2 个值?

go - 使用具有特定本地端口的 net.DialTimeout

go - 将状态存储在golang二进制文件中

Golang Cloud Function 部署失败,第一个路径元素中缺少点