diff --git a/envelope_stream_connector.go b/envelope_stream_connector.go index 378f719..18c53ea 100644 --- a/envelope_stream_connector.go +++ b/envelope_stream_connector.go @@ -3,7 +3,7 @@ package loggregator import ( "context" "crypto/tls" - "io/ioutil" + "io" "log" "time" @@ -41,7 +41,7 @@ func NewEnvelopeStreamConnector( addr: addr, tlsConf: t, - log: log.New(ioutil.Discard, "", 0), + log: log.New(io.Discard, "", 0), } for _, o := range opts { diff --git a/fixtures_test.go b/fixtures_test.go index 38e4349..5644aa5 100644 --- a/fixtures_test.go +++ b/fixtures_test.go @@ -1,8 +1,8 @@ package loggregator_test import ( - "io/ioutil" "log" + "os" ) //go:generate go get github.com/loggregator/go-bindata/... @@ -13,7 +13,7 @@ import ( func fixture(filename string) string { contents := MustAsset(filename) - tmpfile, err := ioutil.TempFile("", "") + tmpfile, err := os.CreateTemp("", "") if err != nil { log.Fatal(err) } diff --git a/ingress_client.go b/ingress_client.go index ff6402b..8b419b2 100644 --- a/ingress_client.go +++ b/ingress_client.go @@ -3,7 +3,7 @@ package loggregator import ( "crypto/tls" "fmt" - "io/ioutil" + "io" "log" "strconv" "time" @@ -121,7 +121,7 @@ func NewIngressClient(tlsConfig *tls.Config, opts ...IngressOption) (*IngressCli batchMaxSize: 100, batchFlushInterval: 100 * time.Millisecond, addr: "localhost:3458", - logger: log.New(ioutil.Discard, "", 0), + logger: log.New(io.Discard, "", 0), closeErrors: make(chan error), ctx: context.Background(), } diff --git a/pulseemitter/pulseemitter_suite_test.go b/pulseemitter/pulseemitter_suite_test.go index 349a52d..4a82e3a 100644 --- a/pulseemitter/pulseemitter_suite_test.go +++ b/pulseemitter/pulseemitter_suite_test.go @@ -1,7 +1,7 @@ package pulseemitter_test import ( - "io/ioutil" + "io" "log" . "github.com/onsi/ginkgo/v2" @@ -12,8 +12,9 @@ import ( ) func TestMetricemitter(t *testing.T) { - grpclog.SetLoggerV2(grpclog.NewLoggerV2(GinkgoWriter, ioutil.Discard, ioutil.Discard)) + grpclog.SetLoggerV2(grpclog.NewLoggerV2(GinkgoWriter, io.Discard, io.Discard)) log.SetOutput(GinkgoWriter) + RegisterFailHandler(Fail) RunSpecs(t, "Pulse Emitter Suite") } diff --git a/rfc5424/stream.go b/rfc5424/stream.go index 9cc56ca..e9eeb1e 100644 --- a/rfc5424/stream.go +++ b/rfc5424/stream.go @@ -3,7 +3,6 @@ package rfc5424 import ( "fmt" "io" - "io/ioutil" "strconv" ) @@ -48,7 +47,7 @@ func (m *Message) ReadFrom(r io.Reader) (int64, error) { return 0, err } r2 := io.LimitReader(r, int64(length)) - buf, err := ioutil.ReadAll(r2) + buf, err := io.ReadAll(r2) if err != nil { return int64(n1 + len(buf)), err } diff --git a/rlp_gateway_client.go b/rlp_gateway_client.go index cce4564..3fde29e 100644 --- a/rlp_gateway_client.go +++ b/rlp_gateway_client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "net/http" "strings" @@ -33,7 +32,7 @@ type GatewayLogger interface { func NewRLPGatewayClient(addr string, opts ...RLPGatewayClientOption) *RLPGatewayClient { c := &RLPGatewayClient{ addr: addr, - log: log.New(ioutil.Discard, "", 0), + log: log.New(io.Discard, "", 0), doer: http.DefaultClient, maxRetries: 10, } @@ -159,12 +158,12 @@ func (c *RLPGatewayClient) connect( } defer func() { - _, _ = io.Copy(ioutil.Discard, resp.Body) + _, _ = io.Copy(io.Discard, resp.Body) _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { c.log.Printf("failed to read body: %s", err) return false diff --git a/rlp_gateway_client_test.go b/rlp_gateway_client_test.go index f60abfc..468f74c 100644 --- a/rlp_gateway_client_test.go +++ b/rlp_gateway_client_test.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "net/http" "sync" @@ -43,7 +42,7 @@ var _ = Describe("RlpGatewayClient", func() { defer close(ch) spyDoer.resps = append(spyDoer.resps, &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(channelReader(ch)), + Body: io.NopCloser(channelReader(ch)), }) spyDoer.errs = []error{nil} @@ -79,7 +78,7 @@ var _ = Describe("RlpGatewayClient", func() { defer close(ch) spyDoer.resps = append(spyDoer.resps, &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(channelReader(ch)), + Body: io.NopCloser(channelReader(ch)), }) spyDoer.errs = []error{nil} @@ -184,7 +183,7 @@ var _ = Describe("RlpGatewayClient", func() { defer close(ch) spyDoer.resps = append(spyDoer.resps, &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(channelReader(ch)), + Body: io.NopCloser(channelReader(ch)), }) spyDoer.errs = []error{nil} @@ -222,7 +221,7 @@ var _ = Describe("RlpGatewayClient", func() { ch := make(chan []byte, 100) spyDoer.resps = append(spyDoer.resps, &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(channelReader(ch)), + Body: io.NopCloser(channelReader(ch)), }) spyDoer.errs = []error{nil} @@ -251,11 +250,11 @@ var _ = Describe("RlpGatewayClient", func() { spyDoer.resps = append(spyDoer.resps, &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(channelReader(ch)), + Body: io.NopCloser(channelReader(ch)), }, &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(channelReader(noCloseCh)), + Body: io.NopCloser(channelReader(noCloseCh)), }) spyDoer.errs = []error{nil, nil} @@ -278,7 +277,7 @@ var _ = Describe("RlpGatewayClient", func() { spyDoer.resps = append(spyDoer.resps, &http.Response{StatusCode: 500}) spyDoer.resps = append(spyDoer.resps, &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(channelReader(ch)), + Body: io.NopCloser(channelReader(ch)), }) spyDoer.errs = []error{nil, nil, nil} ctx, cancel := context.WithCancel(context.Background()) @@ -300,7 +299,7 @@ var _ = Describe("RlpGatewayClient", func() { defer close(ch) spyDoer.resps = append(spyDoer.resps, &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(channelReader(ch)), + Body: io.NopCloser(channelReader(ch)), }) spyDoer.errs = append(spyDoer.errs, nil) ctx, cancel := context.WithCancel(context.Background()) @@ -395,7 +394,7 @@ var _ = Describe("RlpGatewayClient", func() { ch := make(chan []byte, 100) spyDoer.resps = append(spyDoer.resps, &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(channelReader(ch)), + Body: io.NopCloser(channelReader(ch)), }) spyDoer.errs = append(spyDoer.errs, nil) @@ -446,14 +445,14 @@ func (s *spyDoer) Do(r *http.Request) (*http.Response, error) { if s.onlyErrs { return &http.Response{ StatusCode: http.StatusOK, - Body: ioutil.NopCloser(bytes.NewReader(nil)), + Body: io.NopCloser(bytes.NewReader(nil)), }, errors.New("default error") } if len(s.resps) == 0 { return &http.Response{ StatusCode: http.StatusOK, - Body: ioutil.NopCloser(bytes.NewReader(nil)), + Body: io.NopCloser(bytes.NewReader(nil)), }, nil } @@ -461,7 +460,7 @@ func (s *spyDoer) Do(r *http.Request) (*http.Response, error) { s.resps, s.errs = s.resps[1:], s.errs[1:] if resp.Body == nil { - resp.Body = ioutil.NopCloser(bytes.NewReader(nil)) + resp.Body = io.NopCloser(bytes.NewReader(nil)) } return resp, err diff --git a/suite_test.go b/suite_test.go index 27a368a..1ee192c 100644 --- a/suite_test.go +++ b/suite_test.go @@ -1,7 +1,7 @@ package loggregator_test import ( - "io/ioutil" + "io" "log" . "github.com/onsi/ginkgo/v2" @@ -12,8 +12,9 @@ import ( ) func TestGoLoggregator(t *testing.T) { - grpclog.SetLoggerV2(grpclog.NewLoggerV2(GinkgoWriter, ioutil.Discard, ioutil.Discard)) + grpclog.SetLoggerV2(grpclog.NewLoggerV2(GinkgoWriter, io.Discard, io.Discard)) log.SetOutput(GinkgoWriter) + RegisterFailHandler(Fail) RunSpecs(t, "GoLoggregator Suite") }