diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-14 02:37:23 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-14 02:37:35 -0500 |
commit | 1ac9db65fda0693d13336e6471a858914348f2fc (patch) | |
tree | bf53443c9958689fe1a049934faa4393418c2aa1 /sd_id128/get.go | |
parent | 963644c19058829f74bd7d19a484c0786d6777cd (diff) |
sd_id128: use ioutil.ReadFile instead of rolling my own readfile.
Diffstat (limited to 'sd_id128/get.go')
-rw-r--r-- | sd_id128/get.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sd_id128/get.go b/sd_id128/get.go index d8cdcfa..40d1219 100644 --- a/sd_id128/get.go +++ b/sd_id128/get.go @@ -17,6 +17,7 @@ package sd_id128 import ( "crypto/rand" "os" + "io/ioutil" "strings" ) @@ -61,11 +62,11 @@ var cachedMachineID ID128 // machine-id(5): https://www.freedesktop.org/software/systemd/man/machine-id.html func GetMachineID() (ID128, error) { if cachedMachineID == (ID128{}) { - str, err := readfile("/etc/machine-id") + str, err := ioutil.ReadFile("/etc/machine-id") if err != nil { return ID128{}, err } - id, err := ParsePlain(strings.TrimSuffix(str, "\n")) + id, err := ParsePlain(strings.TrimSuffix(string(str), "\n")) if err != nil { return ID128{}, err } @@ -94,11 +95,11 @@ var cachedBootID ID128 // random(4): http://man7.org/linux/man-pages/man4/random.4.html func GetBootUUID() (ID128, error) { if cachedBootID == (ID128{}) { - str, err := readfile("/proc/sys/kernel/random/boot_id") + str, err := ioutil.ReadFile("/proc/sys/kernel/random/boot_id") if err != nil { return ID128{}, err } - id, err := ParseUUID(strings.TrimSuffix(str, "\n")) + id, err := ParseUUID(strings.TrimSuffix(string(str), "\n")) if err != nil { return ID128{}, err } |