all: replace io/ioutil with io and os package
For golang/go#45557 Change-Id: I447530cc66896aef7a8d528ccb8d095b80e3cf47 GitHub-Last-Rev: 5f385ff46487ac318bd1147cdbbd26bb0ffd0426 GitHub-Pull-Request: golang/crypto#230 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/430797 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Meng Zhuo <mzh@golangcn.org> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
@@ -7,7 +7,7 @@ package armor
|
||||
import (
|
||||
"bytes"
|
||||
"hash/adler32"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestDecodeEncode(t *testing.T) {
|
||||
t.Errorf("result.Header: got:%#v", result.Header)
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(result.Body)
|
||||
contents, err := io.ReadAll(result.Body)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -25,7 +24,7 @@ func TestCompressed(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(c.Body)
|
||||
contents, err := io.ReadAll(c.Body)
|
||||
if err != nil && err != io.EOF {
|
||||
t.Error(err)
|
||||
return
|
||||
|
||||
@@ -7,7 +7,6 @@ package packet
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"golang.org/x/crypto/openpgp/errors"
|
||||
)
|
||||
@@ -26,7 +25,7 @@ type OpaquePacket struct {
|
||||
}
|
||||
|
||||
func (op *OpaquePacket) parse(r io.Reader) (err error) {
|
||||
op.Contents, err = ioutil.ReadAll(r)
|
||||
op.Contents, err = io.ReadAll(r)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"fmt"
|
||||
"golang.org/x/crypto/openpgp/errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -100,7 +99,7 @@ var partialLengthReaderTests = []struct {
|
||||
func TestPartialLengthReader(t *testing.T) {
|
||||
for i, test := range partialLengthReaderTests {
|
||||
r := &partialLengthReader{readerFromHex(test.hexInput), 0, true}
|
||||
out, err := ioutil.ReadAll(r)
|
||||
out, err := io.ReadAll(r)
|
||||
if test.err != nil {
|
||||
if err != test.err {
|
||||
t.Errorf("%d: expected different error got:%s want:%s", i, err, test.err)
|
||||
@@ -172,7 +171,7 @@ func TestReadHeader(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(contents)
|
||||
body, err := io.ReadAll(contents)
|
||||
if err != nil {
|
||||
if !test.unexpectedEOF || err != io.ErrUnexpectedEOF {
|
||||
t.Errorf("%d: unexpected error from contents: %s", i, err)
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"crypto/rsa"
|
||||
"crypto/sha1"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -133,7 +132,7 @@ func (pk *PrivateKey) parse(r io.Reader) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
pk.encryptedData, err = ioutil.ReadAll(r)
|
||||
pk.encryptedData, err = io.ReadAll(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"crypto"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/crypto/openpgp/armor"
|
||||
@@ -45,7 +44,7 @@ func TestSignatureV3Reserialize(t *testing.T) {
|
||||
t.Errorf("error reserializing: %s", err)
|
||||
return
|
||||
}
|
||||
expected, err := ioutil.ReadAll(v3KeyReader(t))
|
||||
expected, err := io.ReadAll(v3KeyReader(t))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -46,7 +45,7 @@ func TestSymmetricKeyEncrypted(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(r)
|
||||
contents, err := io.ReadAll(r)
|
||||
if err != nil && err != io.EOF {
|
||||
t.Error(err)
|
||||
return
|
||||
|
||||
@@ -236,7 +236,7 @@ func (w *seMDCWriter) Close() (err error) {
|
||||
return w.w.Close()
|
||||
}
|
||||
|
||||
// noOpCloser is like an ioutil.NopCloser, but for an io.Writer.
|
||||
// noOpCloser is like an io.NopCloser, but for an io.Writer.
|
||||
type noOpCloser struct {
|
||||
w io.Writer
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"encoding/hex"
|
||||
"golang.org/x/crypto/openpgp/errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -42,7 +41,7 @@ func testMDCReader(t *testing.T) {
|
||||
for stride := 1; stride < len(mdcPlaintext)/2; stride++ {
|
||||
r := &testReader{data: mdcPlaintext, stride: stride}
|
||||
mdcReader := &seMDCReader{in: r, h: sha1.New()}
|
||||
body, err := ioutil.ReadAll(mdcReader)
|
||||
body, err := io.ReadAll(mdcReader)
|
||||
if err != nil {
|
||||
t.Errorf("stride: %d, error: %s", stride, err)
|
||||
continue
|
||||
@@ -62,7 +61,7 @@ func testMDCReader(t *testing.T) {
|
||||
|
||||
r := &testReader{data: mdcPlaintext, stride: 2}
|
||||
mdcReader := &seMDCReader{in: r, h: sha1.New()}
|
||||
_, err := ioutil.ReadAll(mdcReader)
|
||||
_, err := io.ReadAll(mdcReader)
|
||||
if err != nil {
|
||||
t.Errorf("corruption test, error: %s", err)
|
||||
return
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"image"
|
||||
"image/jpeg"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
const UserAttrImageSubpacket = 1
|
||||
@@ -56,7 +55,7 @@ func NewUserAttribute(contents ...*OpaqueSubpacket) *UserAttribute {
|
||||
|
||||
func (uat *UserAttribute) parse(r io.Reader) (err error) {
|
||||
// RFC 4880, section 5.13
|
||||
b, err := ioutil.ReadAll(r)
|
||||
b, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ package packet
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -66,7 +65,7 @@ func NewUserId(name, comment, email string) *UserId {
|
||||
|
||||
func (uid *UserId) parse(r io.Reader) (err error) {
|
||||
// RFC 4880, section 5.11
|
||||
b, err := ioutil.ReadAll(r)
|
||||
b, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
_ "crypto/sha512"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -128,7 +127,7 @@ func checkSignedMessage(t *testing.T, signedHex, expected string) {
|
||||
t.Errorf("bad MessageDetails: %#v", md)
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(md.UnverifiedBody)
|
||||
contents, err := io.ReadAll(md.UnverifiedBody)
|
||||
if err != nil {
|
||||
t.Errorf("error reading UnverifiedBody: %s", err)
|
||||
}
|
||||
@@ -221,7 +220,7 @@ func TestSignedEncryptedMessage(t *testing.T) {
|
||||
t.Errorf("#%d: bad MessageDetails: %#v", i, md)
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(md.UnverifiedBody)
|
||||
contents, err := io.ReadAll(md.UnverifiedBody)
|
||||
if err != nil {
|
||||
t.Errorf("#%d: error reading UnverifiedBody: %s", i, err)
|
||||
}
|
||||
@@ -245,7 +244,7 @@ func TestUnspecifiedRecipient(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(md.UnverifiedBody)
|
||||
contents, err := io.ReadAll(md.UnverifiedBody)
|
||||
if err != nil {
|
||||
t.Errorf("error reading UnverifiedBody: %s", err)
|
||||
}
|
||||
@@ -280,7 +279,7 @@ func TestSymmetricallyEncrypted(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(md.UnverifiedBody)
|
||||
contents, err := io.ReadAll(md.UnverifiedBody)
|
||||
if err != nil {
|
||||
t.Errorf("ReadAll: %s", err)
|
||||
}
|
||||
@@ -454,7 +453,7 @@ func TestSignatureV3Message(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = ioutil.ReadAll(md.UnverifiedBody)
|
||||
_, err = io.ReadAll(md.UnverifiedBody)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
|
||||
+1
-1
@@ -402,7 +402,7 @@ func (s signatureWriter) Close() error {
|
||||
return s.encryptedData.Close()
|
||||
}
|
||||
|
||||
// noOpCloser is like an ioutil.NopCloser, but for an io.Writer.
|
||||
// noOpCloser is like an io.NopCloser, but for an io.Writer.
|
||||
// TODO: we have two of these in OpenPGP packages alone. This probably needs
|
||||
// to be promoted somewhere more common.
|
||||
type noOpCloser struct {
|
||||
|
||||
@@ -7,7 +7,6 @@ package openpgp
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -245,7 +244,7 @@ func TestEncryption(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
plaintext, err := ioutil.ReadAll(md.UnverifiedBody)
|
||||
plaintext, err := io.ReadAll(md.UnverifiedBody)
|
||||
if err != nil {
|
||||
t.Errorf("#%d: error reading encrypted contents: %s", i, err)
|
||||
continue
|
||||
@@ -342,7 +341,7 @@ func TestSigning(t *testing.T) {
|
||||
t.Errorf("#%d: failed to find the signing Entity", i)
|
||||
}
|
||||
|
||||
plaintext, err := ioutil.ReadAll(md.UnverifiedBody)
|
||||
plaintext, err := io.ReadAll(md.UnverifiedBody)
|
||||
if err != nil {
|
||||
t.Errorf("#%d: error reading contents: %v", i, err)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user