Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove calls to deprecated ioutil package. #109

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hostid_linux.go
Original file line number Diff line number Diff line change
@@ -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
@@ -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"
@@ -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))
}