Skip to content

Commit

Permalink
Remove calls to deprecated ioutil package. (#109)
Browse files Browse the repository at this point in the history
* xid: Remove usage of deprecated ioutil package

* xid: Remove auto-added generate tag
  • Loading branch information
nickcorin authored Nov 4, 2024
1 parent 18ae5e3 commit 3f489c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions hostid_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

package xid

import "io/ioutil"
import "os"

func readPlatformMachineID() (string, error) {
b, err := ioutil.ReadFile("/etc/machine-id")
b, err := os.ReadFile("/etc/machine-id")
if err != nil || len(b) == 0 {
b, err = ioutil.ReadFile("/sys/class/dmi/id/product_uuid")
b, err = os.ReadFile("/sys/class/dmi/id/product_uuid")
}
return string(b), err
}
5 changes: 2 additions & 3 deletions id.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ package xid

import (
"bytes"
"crypto/sha256"
"crypto/rand"
"crypto/sha256"
"database/sql/driver"
"encoding/binary"
"fmt"
"hash/crc32"
"io/ioutil"
"os"
"sort"
"sync/atomic"
Expand Down Expand Up @@ -98,7 +97,7 @@ func init() {
// If /proc/self/cpuset exists and is not /, we can assume that we are in a
// form of container and use the content of cpuset xor-ed with the PID in
// order get a reasonable machine global unique PID.
b, err := ioutil.ReadFile("/proc/self/cpuset")
b, err := os.ReadFile("/proc/self/cpuset")
if err == nil && len(b) > 1 {
pid ^= int(crc32.ChecksumIEEE(b))
}
Expand Down

0 comments on commit 3f489c4

Please sign in to comment.