Skip to content

Commit a075a1b

Browse files
committed
Use io package in preference to io/ioutil
The latter is deprecated.
1 parent e655a21 commit a075a1b

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

internal/pipe/pipeline.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"fmt"
88
"io"
9-
"io/ioutil"
109
"sync/atomic"
1110
)
1211

@@ -134,7 +133,7 @@ func (p *Pipeline) Start(ctx context.Context) error {
134133
if p.stdin != nil {
135134
// We don't want the first stage to actually close this, and
136135
// it's not even an `io.ReadCloser`, so fake it:
137-
nextStdin = ioutil.NopCloser(p.stdin)
136+
nextStdin = io.NopCloser(p.stdin)
138137
}
139138

140139
for i, s := range p.stages {

internal/pipe/pipeline_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func TestPipelineReadFromSlowly(t *testing.T) {
109109
go func() {
110110
time.Sleep(200 * time.Millisecond)
111111
var err error
112-
buf, err = ioutil.ReadAll(r)
112+
buf, err = io.ReadAll(r)
113113
readErr <- err
114114
}()
115115

@@ -361,7 +361,7 @@ func TestFunction(t *testing.T) {
361361
pipe.Function(
362362
"farewell",
363363
func(_ context.Context, _ pipe.Env, stdin io.Reader, stdout io.Writer) error {
364-
buf, err := ioutil.ReadAll(stdin)
364+
buf, err := io.ReadAll(stdin)
365365
if err != nil {
366366
return err
367367
}
@@ -389,7 +389,7 @@ func TestPipelineWithFunction(t *testing.T) {
389389
pipe.Function(
390390
"farewell",
391391
func(_ context.Context, _ pipe.Env, stdin io.Reader, stdout io.Writer) error {
392-
buf, err := ioutil.ReadAll(stdin)
392+
buf, err := io.ReadAll(stdin)
393393
if err != nil {
394394
return err
395395
}
@@ -419,7 +419,7 @@ func (s ErrorStartingStage) Name() string {
419419
func (s ErrorStartingStage) Start(
420420
ctx context.Context, env pipe.Env, stdin io.ReadCloser,
421421
) (io.ReadCloser, error) {
422-
return ioutil.NopCloser(&bytes.Buffer{}), s.err
422+
return io.NopCloser(&bytes.Buffer{}), s.err
423423
}
424424

425425
func (s ErrorStartingStage) Wait() error {
@@ -525,7 +525,7 @@ func TestScannerAlwaysFlushes(t *testing.T) {
525525
"compute-length",
526526
func(_ context.Context, _ pipe.Env, stdin io.Reader, _ io.Writer) error {
527527
var err error
528-
length, err = io.Copy(ioutil.Discard, stdin)
528+
length, err = io.Copy(io.Discard, stdin)
529529
return err
530530
},
531531
),
@@ -567,7 +567,7 @@ func TestScannerFinishEarly(t *testing.T) {
567567
"compute-length",
568568
func(_ context.Context, _ pipe.Env, stdin io.Reader, _ io.Writer) error {
569569
var err error
570-
length, err = io.Copy(ioutil.Discard, stdin)
570+
length, err = io.Copy(io.Discard, stdin)
571571
return err
572572
},
573573
),

internal/testutils/repoutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func (repo *TestRepo) CreateObject(
196196
t.FailNow()
197197
}
198198

199-
output, err := ioutil.ReadAll(out)
199+
output, err := io.ReadAll(out)
200200
err2 = cmd.Wait()
201201
require.NoError(t, err)
202202
require.NoError(t, err2)

0 commit comments

Comments
 (0)