diff --git a/conn_linux_test.go b/conn_linux_test.go index 2c13545..adcca19 100644 --- a/conn_linux_test.go +++ b/conn_linux_test.go @@ -2,7 +2,6 @@ package dbus import ( "bufio" - "io/ioutil" "os" "os/exec" "syscall" @@ -46,7 +45,7 @@ func startDaemonInDifferentUserNamespace(t *testing.T) (string, *os.Process) { ` - cfg, err := ioutil.TempFile("", "") + cfg, err := os.CreateTemp("", "") if err != nil { t.Fatal(err) } diff --git a/conn_other.go b/conn_other.go index 067e67c..1e99594 100644 --- a/conn_other.go +++ b/conn_other.go @@ -7,7 +7,6 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" "os" "os/exec" "os/user" @@ -61,7 +60,7 @@ func tryDiscoverDbusSessionBusAddress() string { // text file // containing the address of the socket, e.g.: // DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E1c73yNqrG - if f, err := ioutil.ReadFile(runUserSessionDbusFile); err == nil { + if f, err := os.ReadFile(runUserSessionDbusFile); err == nil { fileContent := string(f) prefix := "DBUS_SESSION_BUS_ADDRESS=" diff --git a/conn_test.go b/conn_test.go index 9f64eca..f94dc96 100644 --- a/conn_test.go +++ b/conn_test.go @@ -5,7 +5,6 @@ import ( "encoding/binary" "fmt" "io" - "io/ioutil" "log" "sync" "testing" @@ -171,7 +170,7 @@ func TestCloseBeforeSignal(t *testing.T) { defer pipewriter.Close() defer reader.Close() - bus, err := NewConn(rwc{Reader: reader, Writer: ioutil.Discard}) + bus, err := NewConn(rwc{Reader: reader, Writer: io.Discard}) if err != nil { t.Fatal(err) } @@ -743,7 +742,7 @@ func TestDisconnectCancelsConnectionContext(t *testing.T) { defer pipewriter.Close() defer reader.Close() - bus, err := NewConn(rwc{Reader: reader, Writer: ioutil.Discard}) + bus, err := NewConn(rwc{Reader: reader, Writer: io.Discard}) if err != nil { t.Fatal(err) } @@ -778,7 +777,7 @@ func TestCancellingContextClosesConnection(t *testing.T) { defer pipewriter.Close() defer reader.Close() - bus, err := NewConn(rwc{Reader: reader, Writer: ioutil.Discard}, WithContext(ctx)) + bus, err := NewConn(rwc{Reader: reader, Writer: io.Discard}, WithContext(ctx)) if err != nil { t.Fatal(err) } diff --git a/proto_test.go b/proto_test.go index 5352e0a..534a9ee 100644 --- a/proto_test.go +++ b/proto_test.go @@ -3,7 +3,7 @@ package dbus import ( "bytes" "encoding/binary" - "io/ioutil" + "io" "math" "reflect" "testing" @@ -371,7 +371,7 @@ func BenchmarkDecodeMessageBig(b *testing.B) { func BenchmarkEncodeMessageSmall(b *testing.B) { var err error for i := 0; i < b.N; i++ { - err = smallMessage.EncodeTo(ioutil.Discard, binary.LittleEndian) + err = smallMessage.EncodeTo(io.Discard, binary.LittleEndian) if err != nil { b.Fatal(err) } @@ -381,7 +381,7 @@ func BenchmarkEncodeMessageSmall(b *testing.B) { func BenchmarkEncodeMessageBig(b *testing.B) { var err error for i := 0; i < b.N; i++ { - err = bigMessage.EncodeTo(ioutil.Discard, binary.LittleEndian) + err = bigMessage.EncodeTo(io.Discard, binary.LittleEndian) if err != nil { b.Fatal(err) } diff --git a/transport_nonce_tcp.go b/transport_nonce_tcp.go index a61a820..a08d089 100644 --- a/transport_nonce_tcp.go +++ b/transport_nonce_tcp.go @@ -5,8 +5,8 @@ package dbus import ( "errors" - "io/ioutil" "net" + "os" ) func init() { @@ -28,7 +28,7 @@ func newNonceTcpTransport(keys string) (transport, error) { if err != nil { return nil, err } - b, err := ioutil.ReadFile(noncefile) + b, err := os.ReadFile(noncefile) if err != nil { return nil, err } diff --git a/transport_nonce_tcp_test.go b/transport_nonce_tcp_test.go index c9075c3..a941584 100644 --- a/transport_nonce_tcp_test.go +++ b/transport_nonce_tcp_test.go @@ -2,7 +2,6 @@ package dbus import ( "bufio" - "io/ioutil" "os" "os/exec" "testing" @@ -38,7 +37,7 @@ func TestTcpNonceConnection(t *testing.T) { // startDaemon starts a dbus-daemon instance with the given config // and returns its address string and underlying process. func startDaemon(t *testing.T, config string) (string, *os.Process) { - cfg, err := ioutil.TempFile("", "") + cfg, err := os.CreateTemp("", "") if err != nil { t.Fatal(err) }