Skip to content

Commit

Permalink
Merge pull request #486 from capnproto/cleanup/ioutil
Browse files Browse the repository at this point in the history
Expunge io/ioutil
  • Loading branch information
zenhack authored Mar 23, 2023
2 parents 6ed9a14 + 297083b commit cd7f020
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions capnpc-go/capnpc-go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"go/parser"
"go/token"
"io/ioutil"
"os"
"path/filepath"
"sort"
"strconv"
Expand All @@ -19,7 +19,7 @@ import (

func readTestFile(name string) ([]byte, error) {
path := filepath.Join("testdata", name)
return ioutil.ReadFile(path)
return os.ReadFile(path)
}

func mustReadTestFile(t *testing.T, name string) []byte {
Expand Down
4 changes: 2 additions & 2 deletions encoding/text/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package text

import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -13,7 +13,7 @@ import (

func readTestFile(name string) ([]byte, error) {
path := filepath.Join("testdata", name)
return ioutil.ReadFile(path)
return os.ReadFile(path)
}

func TestEncode(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package capnp_test

import (
"fmt"
"io/ioutil"
"os"

"capnproto.org/go/capnp/v3"
Expand Down Expand Up @@ -75,7 +74,7 @@ func Example() {
_ = buf

// ... or write to an io.Writer.
file, err := ioutil.TempFile("", "go-capnproto")
file, err := os.CreateTemp("", "go-capnproto")
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions packed/fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"bufio"
"bytes"
"io"
"io/ioutil"
)

func Fuzz(data []byte) int {
Expand All @@ -26,7 +25,7 @@ func Fuzz(data []byte) int {
// Read
{
r := NewReader(bufio.NewReader(bytes.NewReader(data)))
if unpacked, err := ioutil.ReadAll(r); err == nil {
if unpacked, err := io.ReadAll(r); err == nil {
checkRepack(unpacked)
result = 1
}
Expand Down
5 changes: 2 additions & 3 deletions packed/packed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"math"
"strings"
"testing"
Expand Down Expand Up @@ -381,7 +380,7 @@ func TestReader_Fail(t *testing.T) {
for _, test := range badDecompressionTests {
t.Run(test.name, func(t *testing.T) {
d := NewReader(bufio.NewReader(bytes.NewReader(test.input)))
_, err := ioutil.ReadAll(d)
_, err := io.ReadAll(d)
assert.Error(t, err, "should return error")
})
}
Expand Down Expand Up @@ -521,7 +520,7 @@ func mustGunzip(s string) []byte {
if err != nil {
panic(err)
}
data, err := ioutil.ReadAll(r)
data, err := io.ReadAll(r)
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions schemas/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"compress/zlib"
"errors"
"io"
"io/ioutil"
"strings"
"sync"

Expand Down Expand Up @@ -111,7 +110,7 @@ func (r *record) read() ([]byte, error) {
return
}
p := packed.NewReader(bufio.NewReader(z))
r.data, r.err = ioutil.ReadAll(p)
r.data, r.err = io.ReadAll(p)
if err != nil {
r.data = nil
return
Expand Down

0 comments on commit cd7f020

Please sign in to comment.