Skip to content

Commit efa678f

Browse files
authored
Try /etc/machine-id for linux first (#60)
1 parent ad8ba68 commit efa678f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

hostid_linux.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ package xid
55
import "io/ioutil"
66

77
func readPlatformMachineID() (string, error) {
8-
b, err := ioutil.ReadFile("/sys/class/dmi/id/product_uuid")
8+
b, err := ioutil.ReadFile("/etc/machine-id")
9+
if err != nil || len(b) == 0 {
10+
b, err = ioutil.ReadFile("/sys/class/dmi/id/product_uuid")
11+
}
912
return string(b), err
1013
}

0 commit comments

Comments
 (0)