Want to know a way to get the serial number and make of a laptop using some golang code.
No easy answer for this, as this is OS-specific. One option is to use os/exec
package and parse command output (different command for Windows, Linux and OS X). For example to obtain serial number on:
Windows: wmic bios get serialnumber
Linux: dmidecode -t system
OS X: ioreg -l
Then combined with Go code for OS X case:
out, _ := exec.Command("/usr/sbin/ioreg", "-l").Output() // err ignored for brevity
for _, l := range strings.Split(string(out), "
") {
if strings.Contains(l, "IOPlatformSerialNumber") {
s := strings.Split(l, " ")
fmt.Printf("%s
", s[len(s)-1])
}
}