From efa678f304ab65d6d57eedcb086798381ae22206 Mon Sep 17 00:00:00 2001 From: phuslu Date: Mon, 19 Oct 2020 17:31:50 +0800 Subject: [PATCH] Try /etc/machine-id for linux first (#60) --- hostid_linux.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hostid_linux.go b/hostid_linux.go index 7d0c4a9..837b204 100644 --- a/hostid_linux.go +++ b/hostid_linux.go @@ -5,6 +5,9 @@ package xid import "io/ioutil" func readPlatformMachineID() (string, error) { - b, err := ioutil.ReadFile("/sys/class/dmi/id/product_uuid") + b, err := ioutil.ReadFile("/etc/machine-id") + if err != nil || len(b) == 0 { + b, err = ioutil.ReadFile("/sys/class/dmi/id/product_uuid") + } return string(b), err }