Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill committed Jul 11, 2023
1 parent bb3b928 commit c192c65
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 19 deletions.
3 changes: 1 addition & 2 deletions internal/broker/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net"
"sync"
"testing"
Expand Down Expand Up @@ -228,7 +227,7 @@ func (c *testConn) ReadByte() (byte, error) {

func (c *testConn) Drain() {
for {
if _, err := io.Copy(ioutil.Discard, c.Conn); err != nil {
if _, err := io.Copy(io.Discard, c.Conn); err != nil {
return
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/broker/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package broker

import (
"io/ioutil"
"io"
"testing"

"github.com/emitter-io/emitter/internal/errors"
Expand Down Expand Up @@ -48,7 +48,7 @@ func TestNotifyError(t *testing.T) {
conn.Close()
}()

b, err := ioutil.ReadAll(pipe.Server)
b, err := io.ReadAll(pipe.Server)
assert.Contains(t, string(b), errors.ErrUnauthorized.Message)
assert.NoError(t, err)
}
3 changes: 1 addition & 2 deletions internal/command/load/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net"
"sync/atomic"
"time"
Expand Down Expand Up @@ -144,7 +143,7 @@ func (c *conn) Drain() {
})

for {
if _, err := io.Copy(ioutil.Discard, c.Conn); err != nil {
if _, err := io.Copy(io.Discard, c.Conn); err != nil {
return
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/network/listener/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package listener

import (
"fmt"
"io/ioutil"
"io"
"log"
"net"
"net/http"
Expand Down Expand Up @@ -119,7 +119,7 @@ func runTestHTTP1Client(t *testing.T, addr net.Addr) {
}
}()

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
package logging

import (
"io/ioutil"
"io"
"log"
"os"

"github.com/emitter-io/config"
)

// Discard is the discard logger.
var Discard = log.New(ioutil.Discard, "", 0)
var Discard = log.New(io.Discard, "", 0)

// Logger is the logger we use.
var Logger = NewStdErr()
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/monitor/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package monitor

import (
"io/ioutil"
"io"
netHttp "net/http"
"net/http/httptest"
"testing"
Expand All @@ -32,7 +32,7 @@ func (f handler) ServeHTTP(w netHttp.ResponseWriter, r *netHttp.Request) {
func TestHTTP_HappyPath(t *testing.T) {
r := snapshot("test")
server := httptest.NewServer(handler(func(w netHttp.ResponseWriter, r *netHttp.Request) {
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
assert.Equal(t, "test", string(b))
assert.NoError(t, err)
w.WriteHeader(204)
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/monitor/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package monitor

import (
"io/ioutil"
"io"
"log"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestPrometheus_Request(t *testing.T) {
if err != nil {
log.Fatal(err)
}
content, err := ioutil.ReadAll(res.Body)
content, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
log.Fatal(err)
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/storage/ssd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package storage
import (
"context"
"fmt"
"io/ioutil"
"os"
"runtime"
"sync"
Expand Down Expand Up @@ -46,7 +45,7 @@ func getNTestMessages(count int) (frame message.Frame) {
func runSSDTest(test func(store *SSD)) {

// Prepare a store
dir, _ := ioutil.TempDir("", "emitter")
dir, _ := os.MkdirTemp("", "emitter")
store := NewSSD(nil)
store.Configure(map[string]interface{}{
"dir": dir,
Expand Down
6 changes: 3 additions & 3 deletions internal/service/keygen/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package keygen

import (
"io/ioutil"
"io"
"log"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestRenderKeyGenPage(t *testing.T) {

// act
handler(w, req)
content, err := ioutil.ReadAll(w.Body)
content, err := io.ReadAll(w.Body)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func Test_HTTP(t *testing.T) {

// act
handler(w, req)
content, err := ioutil.ReadAll(w.Body)
content, err := io.ReadAll(w.Body)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit c192c65

Please sign in to comment.