Commit e3b269ea authored by szh's avatar szh

获取主板uuid 优化

parent 80437d8e
......@@ -23,17 +23,26 @@ func GetLocalArchType() string {
}
func GetLocalUuid() string {
cmd := exec.Command("bash","-c","dmidecode | grep UUID")
var buf bytes.Buffer
cmd := exec.Command("dmidecode")
var buf ,errbuf bytes.Buffer
cmd.Stdout = &buf
cmd.Run()
cmd.Stderr = &errbuf
err := cmd.Run()
if err != nil {
fmt.Println("exec uuid",err)
}
fmt.Println("err",errbuf.String())
fmt.Println("uuid",buf.String())
if buf.String() != "" {
lines := strings.Split(buf.String(),"\n")
if len(lines) >0 {
return strings.Trim(lines[0]," ")
for _,l := range lines {
if strings.Contains(l,"UUID") {
return strings.Trim(l," ")
}
}
}
return ""
}
return ""
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment