I am trying get a unique hardware info such as the uuid of a device for a client based application that will have an authentication process.
In python it would be something like:
import subprocess
hwid = str(subprocess.check_output('wmic csproduct get uuid')).split('\\r\\n')[1].strip('\\r').strip()
print(hwid)
Ouput:
9F23624C-33F1-3244-A2ZD-ABF6CC8E5FB5
How do can I replicate this function in go, and assign it to a variable ? uuid := xxx
I found a solution using, os/exec:
package main
import (
"bytes"
"fmt"
"os/exec"
)
func main() {
const xx = "cmd.exe"
var stdout bytes.Buffer
cmd := exec.Command(xx, "/c", "wmic csproduct get uuid")
cmd.Stdout = &stdout
cmd.Run()
out := stdout.String()
fmt.Println(out)
}
Output:
UUID
9F23624C-33F1-3244-A2ZD-ABF6CC8E5FB5