Replace deprecated ioutil

As of Go 1.16, the same functionality is now provided by package io or
package os, and those implementations should be preferred in new code.
This commit is contained in:
albertony 2022-08-20 16:38:02 +02:00 committed by Nick Craig-Wood
parent 776e5ea83a
commit 5d6b8141ec
108 changed files with 295 additions and 359 deletions

View File

@ -12,9 +12,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"os"
"path" "path"
"strconv" "strconv"
"strings" "strings"
@ -717,7 +717,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
return nil, fmt.Errorf("failed to make azure storage url from account and endpoint: %w", err) return nil, fmt.Errorf("failed to make azure storage url from account and endpoint: %w", err)
} }
// Try loading service principal credentials from file. // Try loading service principal credentials from file.
loadedCreds, err := ioutil.ReadFile(env.ShellExpand(opt.ServicePrincipalFile)) loadedCreds, err := os.ReadFile(env.ShellExpand(opt.ServicePrincipalFile))
if err != nil { if err != nil {
return nil, fmt.Errorf("error opening service principal credentials file: %w", err) return nil, fmt.Errorf("error opening service principal credentials file: %w", err)
} }

View File

@ -9,7 +9,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"github.com/Azure/go-autorest/autorest/adal" "github.com/Azure/go-autorest/autorest/adal"
@ -97,7 +96,7 @@ func GetMSIToken(ctx context.Context, identity *userMSI) (adal.Token, error) {
return result, fmt.Errorf("MSI is not enabled on this VM: %w", err) return result, fmt.Errorf("MSI is not enabled on this VM: %w", err)
} }
defer func() { // resp and Body should not be nil defer func() { // resp and Body should not be nil
_, err = io.Copy(ioutil.Discard, resp.Body) _, err = io.Copy(io.Discard, resp.Body)
if err != nil { if err != nil {
fs.Debugf(nil, "Unable to drain IMDS response: %v", err) fs.Debugf(nil, "Unable to drain IMDS response: %v", err)
} }
@ -112,12 +111,12 @@ func GetMSIToken(ctx context.Context, identity *userMSI) (adal.Token, error) {
case 200, 201, 202: case 200, 201, 202:
break break
default: default:
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
fs.Errorf(nil, "Couldn't obtain OAuth token from IMDS; server returned status code %d and body: %v", resp.StatusCode, string(body)) fs.Errorf(nil, "Couldn't obtain OAuth token from IMDS; server returned status code %d and body: %v", resp.StatusCode, string(body))
return result, httpError{Response: resp} return result, httpError{Response: resp}
} }
b, err := ioutil.ReadAll(resp.Body) b, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return result, fmt.Errorf("couldn't read IMDS response: %w", err) return result, fmt.Errorf("couldn't read IMDS response: %w", err)
} }

View File

@ -17,9 +17,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"os"
"path" "path"
"strconv" "strconv"
"strings" "strings"
@ -183,7 +183,7 @@ func refreshJWTToken(ctx context.Context, jsonFile string, boxSubType string, na
} }
func getBoxConfig(configFile string) (boxConfig *api.ConfigJSON, err error) { func getBoxConfig(configFile string) (boxConfig *api.ConfigJSON, err error) {
file, err := ioutil.ReadFile(configFile) file, err := os.ReadFile(configFile)
if err != nil { if err != nil {
return nil, fmt.Errorf("box: failed to read Box config: %w", err) return nil, fmt.Errorf("box: failed to read Box config: %w", err)
} }

View File

@ -11,7 +11,6 @@ import (
goflag "flag" goflag "flag"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"math/rand" "math/rand"
"os" "os"
@ -167,7 +166,7 @@ func TestInternalVfsCache(t *testing.T) {
li2 := [2]string{path.Join("test", "one"), path.Join("test", "second")} li2 := [2]string{path.Join("test", "one"), path.Join("test", "second")}
for _, r := range li2 { for _, r := range li2 {
var err error var err error
ci, err := ioutil.ReadDir(path.Join(runInstance.chunkPath, runInstance.encryptRemoteIfNeeded(t, path.Join(id, r)))) ci, err := os.ReadDir(path.Join(runInstance.chunkPath, runInstance.encryptRemoteIfNeeded(t, path.Join(id, r))))
if err != nil || len(ci) == 0 { if err != nil || len(ci) == 0 {
log.Printf("========== '%v' not in cache", r) log.Printf("========== '%v' not in cache", r)
} else { } else {
@ -841,7 +840,7 @@ func newRun() *run {
} }
if uploadDir == "" { if uploadDir == "" {
r.tmpUploadDir, err = ioutil.TempDir("", "rclonecache-tmp") r.tmpUploadDir, err = os.MkdirTemp("", "rclonecache-tmp")
if err != nil { if err != nil {
panic(fmt.Sprintf("Failed to create temp dir: %v", err)) panic(fmt.Sprintf("Failed to create temp dir: %v", err))
} }
@ -984,7 +983,7 @@ func (r *run) randomReader(t *testing.T, size int64) io.ReadCloser {
chunk := int64(1024) chunk := int64(1024)
cnt := size / chunk cnt := size / chunk
left := size % chunk left := size % chunk
f, err := ioutil.TempFile("", "rclonecache-tempfile") f, err := os.CreateTemp("", "rclonecache-tempfile")
require.NoError(t, err) require.NoError(t, err)
for i := 0; i < int(cnt); i++ { for i := 0; i < int(cnt); i++ {

View File

@ -8,7 +8,7 @@ import (
"crypto/tls" "crypto/tls"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@ -167,7 +167,7 @@ func (p *plexConnector) listenWebsocket() {
continue continue
} }
var data []byte var data []byte
data, err = ioutil.ReadAll(resp.Body) data, err = io.ReadAll(resp.Body)
if err != nil { if err != nil {
continue continue
} }

View File

@ -9,7 +9,6 @@ import (
"encoding/binary" "encoding/binary"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path" "path"
"strconv" "strconv"
@ -473,7 +472,7 @@ func (b *Persistent) GetChunk(cachedObject *Object, offset int64) ([]byte, error
var data []byte var data []byte
fp := path.Join(b.dataPath, cachedObject.abs(), strconv.FormatInt(offset, 10)) fp := path.Join(b.dataPath, cachedObject.abs(), strconv.FormatInt(offset, 10))
data, err := ioutil.ReadFile(fp) data, err := os.ReadFile(fp)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -486,7 +485,7 @@ func (b *Persistent) AddChunk(fp string, data []byte, offset int64) error {
_ = os.MkdirAll(path.Join(b.dataPath, fp), os.ModePerm) _ = os.MkdirAll(path.Join(b.dataPath, fp), os.ModePerm)
filePath := path.Join(b.dataPath, fp, strconv.FormatInt(offset, 10)) filePath := path.Join(b.dataPath, fp, strconv.FormatInt(offset, 10))
err := ioutil.WriteFile(filePath, data, os.ModePerm) err := os.WriteFile(filePath, data, os.ModePerm)
if err != nil { if err != nil {
return err return err
} }

View File

@ -12,7 +12,6 @@ import (
"fmt" "fmt"
gohash "hash" gohash "hash"
"io" "io"
"io/ioutil"
"math/rand" "math/rand"
"path" "path"
"regexp" "regexp"
@ -1038,7 +1037,7 @@ func (o *Object) readMetadata(ctx context.Context) error {
if err != nil { if err != nil {
return err return err
} }
metadata, err := ioutil.ReadAll(reader) metadata, err := io.ReadAll(reader)
_ = reader.Close() // ensure file handle is freed on windows _ = reader.Close() // ensure file handle is freed on windows
if err != nil { if err != nil {
return err return err
@ -1097,7 +1096,7 @@ func (o *Object) readXactID(ctx context.Context) (xactID string, err error) {
if err != nil { if err != nil {
return "", err return "", err
} }
data, err := ioutil.ReadAll(reader) data, err := io.ReadAll(reader)
_ = reader.Close() // ensure file handle is freed on windows _ = reader.Close() // ensure file handle is freed on windows
if err != nil { if err != nil {
return "", err return "", err

View File

@ -5,7 +5,7 @@ import (
"context" "context"
"flag" "flag"
"fmt" "fmt"
"io/ioutil" "io"
"path" "path"
"regexp" "regexp"
"strings" "strings"
@ -413,7 +413,7 @@ func testSmallFileInternals(t *testing.T, f *Fs) {
if r == nil { if r == nil {
return return
} }
data, err := ioutil.ReadAll(r) data, err := io.ReadAll(r)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, contents, string(data)) assert.Equal(t, contents, string(data))
_ = r.Close() _ = r.Close()
@ -538,7 +538,7 @@ func testPreventCorruption(t *testing.T, f *Fs) {
assert.NoError(t, err) assert.NoError(t, err)
var chunkContents []byte var chunkContents []byte
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
chunkContents, err = ioutil.ReadAll(r) chunkContents, err = io.ReadAll(r)
_ = r.Close() _ = r.Close()
}) })
assert.NoError(t, err) assert.NoError(t, err)
@ -573,7 +573,7 @@ func testPreventCorruption(t *testing.T, f *Fs) {
r, err = willyChunk.Open(ctx) r, err = willyChunk.Open(ctx)
assert.NoError(t, err) assert.NoError(t, err)
assert.NotPanics(t, func() { assert.NotPanics(t, func() {
_, err = ioutil.ReadAll(r) _, err = io.ReadAll(r)
_ = r.Close() _ = r.Close()
}) })
assert.NoError(t, err) assert.NoError(t, err)
@ -672,7 +672,7 @@ func testMetadataInput(t *testing.T, f *Fs) {
assert.NoError(t, err, "open "+description) assert.NoError(t, err, "open "+description)
assert.NotNil(t, r, "open stream of "+description) assert.NotNil(t, r, "open stream of "+description)
if err == nil && r != nil { if err == nil && r != nil {
data, err := ioutil.ReadAll(r) data, err := io.ReadAll(r)
assert.NoError(t, err, "read all of "+description) assert.NoError(t, err, "read all of "+description)
assert.Equal(t, contents, string(data), description+" contents is ok") assert.Equal(t, contents, string(data), description+" contents is ok")
_ = r.Close() _ = r.Close()
@ -758,7 +758,7 @@ func testFutureProof(t *testing.T, f *Fs) {
assert.Error(t, err) assert.Error(t, err)
// Rcat must fail // Rcat must fail
in := ioutil.NopCloser(bytes.NewBufferString("abc")) in := io.NopCloser(bytes.NewBufferString("abc"))
robj, err := operations.Rcat(ctx, f, file, in, modTime) robj, err := operations.Rcat(ctx, f, file, in, modTime)
assert.Nil(t, robj) assert.Nil(t, robj)
assert.NotNil(t, err) assert.NotNil(t, err)
@ -854,7 +854,7 @@ func testChunkerServerSideMove(t *testing.T, f *Fs) {
r, err := dstFile.Open(ctx) r, err := dstFile.Open(ctx)
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, r) assert.NotNil(t, r)
data, err := ioutil.ReadAll(r) data, err := io.ReadAll(r)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, contents, string(data)) assert.Equal(t, contents, string(data))
_ = r.Close() _ = r.Close()

View File

@ -13,7 +13,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"regexp" "regexp"
"strings" "strings"
@ -468,7 +467,7 @@ func (f *Fs) rcat(ctx context.Context, dstFileName string, in io.ReadCloser, mod
} }
fs.Debugf(f, "Target remote doesn't support streaming uploads, creating temporary local file") fs.Debugf(f, "Target remote doesn't support streaming uploads, creating temporary local file")
tempFile, err := ioutil.TempFile("", "rclone-press-") tempFile, err := os.CreateTemp("", "rclone-press-")
defer func() { defer func() {
// these errors should be relatively uncritical and the upload should've succeeded so it's okay-ish // these errors should be relatively uncritical and the upload should've succeeded so it's okay-ish
// to ignore them // to ignore them
@ -546,8 +545,8 @@ func (f *Fs) putCompress(ctx context.Context, in io.Reader, src fs.ObjectInfo, o
} }
// Transfer the data // Transfer the data
o, err := f.rcat(ctx, makeDataName(src.Remote(), src.Size(), f.mode), ioutil.NopCloser(wrappedIn), src.ModTime(ctx), options) o, err := f.rcat(ctx, makeDataName(src.Remote(), src.Size(), f.mode), io.NopCloser(wrappedIn), src.ModTime(ctx), options)
//o, err := operations.Rcat(ctx, f.Fs, makeDataName(src.Remote(), src.Size(), f.mode), ioutil.NopCloser(wrappedIn), src.ModTime(ctx)) //o, err := operations.Rcat(ctx, f.Fs, makeDataName(src.Remote(), src.Size(), f.mode), io.NopCloser(wrappedIn), src.ModTime(ctx))
if err != nil { if err != nil {
if o != nil { if o != nil {
removeErr := o.Remove(ctx) removeErr := o.Remove(ctx)

View File

@ -8,7 +8,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"strings" "strings"
"testing" "testing"
@ -1073,7 +1072,7 @@ func testEncryptDecrypt(t *testing.T, bufSize int, copySize int64) {
source := newRandomSource(copySize) source := newRandomSource(copySize)
encrypted, err := c.newEncrypter(source, nil) encrypted, err := c.newEncrypter(source, nil)
assert.NoError(t, err) assert.NoError(t, err)
decrypted, err := c.newDecrypter(ioutil.NopCloser(encrypted)) decrypted, err := c.newDecrypter(io.NopCloser(encrypted))
assert.NoError(t, err) assert.NoError(t, err)
sink := newRandomSource(copySize) sink := newRandomSource(copySize)
n, err := io.CopyBuffer(sink, decrypted, buf) n, err := io.CopyBuffer(sink, decrypted, buf)
@ -1144,15 +1143,15 @@ func TestEncryptData(t *testing.T) {
buf := bytes.NewBuffer(test.in) buf := bytes.NewBuffer(test.in)
encrypted, err := c.EncryptData(buf) encrypted, err := c.EncryptData(buf)
assert.NoError(t, err) assert.NoError(t, err)
out, err := ioutil.ReadAll(encrypted) out, err := io.ReadAll(encrypted)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, test.expected, out) assert.Equal(t, test.expected, out)
// Check we can decode the data properly too... // Check we can decode the data properly too...
buf = bytes.NewBuffer(out) buf = bytes.NewBuffer(out)
decrypted, err := c.DecryptData(ioutil.NopCloser(buf)) decrypted, err := c.DecryptData(io.NopCloser(buf))
assert.NoError(t, err) assert.NoError(t, err)
out, err = ioutil.ReadAll(decrypted) out, err = io.ReadAll(decrypted)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, test.in, out) assert.Equal(t, test.in, out)
} }
@ -1187,7 +1186,7 @@ func TestNewEncrypterErrUnexpectedEOF(t *testing.T) {
fh, err := c.newEncrypter(in, nil) fh, err := c.newEncrypter(in, nil)
assert.NoError(t, err) assert.NoError(t, err)
n, err := io.CopyN(ioutil.Discard, fh, 1e6) n, err := io.CopyN(io.Discard, fh, 1e6)
assert.Equal(t, io.ErrUnexpectedEOF, err) assert.Equal(t, io.ErrUnexpectedEOF, err)
assert.Equal(t, int64(32), n) assert.Equal(t, int64(32), n)
} }
@ -1257,12 +1256,12 @@ func TestNewDecrypterErrUnexpectedEOF(t *testing.T) {
in2 := &readers.ErrorReader{Err: io.ErrUnexpectedEOF} in2 := &readers.ErrorReader{Err: io.ErrUnexpectedEOF}
in1 := bytes.NewBuffer(file16) in1 := bytes.NewBuffer(file16)
in := ioutil.NopCloser(io.MultiReader(in1, in2)) in := io.NopCloser(io.MultiReader(in1, in2))
fh, err := c.newDecrypter(in) fh, err := c.newDecrypter(in)
assert.NoError(t, err) assert.NoError(t, err)
n, err := io.CopyN(ioutil.Discard, fh, 1e6) n, err := io.CopyN(io.Discard, fh, 1e6)
assert.Equal(t, io.ErrUnexpectedEOF, err) assert.Equal(t, io.ErrUnexpectedEOF, err)
assert.Equal(t, int64(16), n) assert.Equal(t, int64(16), n)
} }
@ -1274,14 +1273,14 @@ func TestNewDecrypterSeekLimit(t *testing.T) {
// Make random data // Make random data
const dataSize = 150000 const dataSize = 150000
plaintext, err := ioutil.ReadAll(newRandomSource(dataSize)) plaintext, err := io.ReadAll(newRandomSource(dataSize))
assert.NoError(t, err) assert.NoError(t, err)
// Encrypt the data // Encrypt the data
buf := bytes.NewBuffer(plaintext) buf := bytes.NewBuffer(plaintext)
encrypted, err := c.EncryptData(buf) encrypted, err := c.EncryptData(buf)
assert.NoError(t, err) assert.NoError(t, err)
ciphertext, err := ioutil.ReadAll(encrypted) ciphertext, err := io.ReadAll(encrypted)
assert.NoError(t, err) assert.NoError(t, err)
trials := []int{0, 1, 2, 3, 4, 5, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65, trials := []int{0, 1, 2, 3, 4, 5, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65,
@ -1300,7 +1299,7 @@ func TestNewDecrypterSeekLimit(t *testing.T) {
end = len(ciphertext) end = len(ciphertext)
} }
} }
reader = ioutil.NopCloser(bytes.NewBuffer(ciphertext[int(underlyingOffset):end])) reader = io.NopCloser(bytes.NewBuffer(ciphertext[int(underlyingOffset):end]))
return reader, nil return reader, nil
} }
@ -1490,7 +1489,7 @@ func TestDecrypterRead(t *testing.T) {
assert.NoError(t, err, what) assert.NoError(t, err, what)
continue continue
} }
_, err = ioutil.ReadAll(fh) _, err = io.ReadAll(fh)
var expectedErr error var expectedErr error
switch { switch {
case i == fileHeaderSize: case i == fileHeaderSize:
@ -1514,7 +1513,7 @@ func TestDecrypterRead(t *testing.T) {
cd := newCloseDetector(in) cd := newCloseDetector(in)
fh, err := c.newDecrypter(cd) fh, err := c.newDecrypter(cd)
assert.NoError(t, err) assert.NoError(t, err)
_, err = ioutil.ReadAll(fh) _, err = io.ReadAll(fh)
assert.Error(t, err, "potato") assert.Error(t, err, "potato")
assert.Equal(t, 0, cd.closed) assert.Equal(t, 0, cd.closed)
@ -1524,13 +1523,13 @@ func TestDecrypterRead(t *testing.T) {
copy(file16copy, file16) copy(file16copy, file16)
for i := range file16copy { for i := range file16copy {
file16copy[i] ^= 0xFF file16copy[i] ^= 0xFF
fh, err := c.newDecrypter(ioutil.NopCloser(bytes.NewBuffer(file16copy))) fh, err := c.newDecrypter(io.NopCloser(bytes.NewBuffer(file16copy)))
if i < fileMagicSize { if i < fileMagicSize {
assert.Error(t, err, ErrorEncryptedBadMagic.Error()) assert.Error(t, err, ErrorEncryptedBadMagic.Error())
assert.Nil(t, fh) assert.Nil(t, fh)
} else { } else {
assert.NoError(t, err) assert.NoError(t, err)
_, err = ioutil.ReadAll(fh) _, err = io.ReadAll(fh)
assert.Error(t, err, ErrorEncryptedFileBadHeader.Error()) assert.Error(t, err, ErrorEncryptedFileBadHeader.Error())
} }
file16copy[i] ^= 0xFF file16copy[i] ^= 0xFF
@ -1565,7 +1564,7 @@ func TestDecrypterClose(t *testing.T) {
assert.Equal(t, 0, cd.closed) assert.Equal(t, 0, cd.closed)
// close after reading // close after reading
out, err := ioutil.ReadAll(fh) out, err := io.ReadAll(fh)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, []byte{1}, out) assert.Equal(t, []byte{1}, out)
assert.Equal(t, io.EOF, fh.err) assert.Equal(t, io.EOF, fh.err)

View File

@ -14,9 +14,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"mime" "mime"
"net/http" "net/http"
"os"
"path" "path"
"regexp" "regexp"
"sort" "sort"
@ -1108,7 +1108,7 @@ func createOAuthClient(ctx context.Context, opt *Options, name string, m configm
// try loading service account credentials from env variable, then from a file // try loading service account credentials from env variable, then from a file
if len(opt.ServiceAccountCredentials) == 0 && opt.ServiceAccountFile != "" { if len(opt.ServiceAccountCredentials) == 0 && opt.ServiceAccountFile != "" {
loadedCreds, err := ioutil.ReadFile(env.ShellExpand(opt.ServiceAccountFile)) loadedCreds, err := os.ReadFile(env.ShellExpand(opt.ServiceAccountFile))
if err != nil { if err != nil {
return nil, fmt.Errorf("error opening service account credentials file: %w", err) return nil, fmt.Errorf("error opening service account credentials file: %w", err)
} }
@ -3800,7 +3800,7 @@ func (o *linkObject) Open(ctx context.Context, options ...fs.OpenOption) (in io.
data = data[:limit] data = data[:limit]
} }
return ioutil.NopCloser(bytes.NewReader(data)), nil return io.NopCloser(bytes.NewReader(data)), nil
} }
func (o *baseObject) update(ctx context.Context, updateInfo *drive.File, uploadMimeType string, in io.Reader, func (o *baseObject) update(ctx context.Context, updateInfo *drive.File, uploadMimeType string, in io.Reader,

View File

@ -7,7 +7,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"mime" "mime"
"os" "os"
"path" "path"
@ -78,7 +77,7 @@ var additionalMimeTypes = map[string]string{
// Load the example export formats into exportFormats for testing // Load the example export formats into exportFormats for testing
func TestInternalLoadExampleFormats(t *testing.T) { func TestInternalLoadExampleFormats(t *testing.T) {
fetchFormatsOnce.Do(func() {}) fetchFormatsOnce.Do(func() {})
buf, err := ioutil.ReadFile(filepath.FromSlash("test/about.json")) buf, err := os.ReadFile(filepath.FromSlash("test/about.json"))
var about struct { var about struct {
ExportFormats map[string][]string `json:"exportFormats,omitempty"` ExportFormats map[string][]string `json:"exportFormats,omitempty"`
ImportFormats map[string][]string `json:"importFormats,omitempty"` ImportFormats map[string][]string `json:"importFormats,omitempty"`

View File

@ -20,7 +20,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -1186,7 +1185,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
return nil, errors.New("can't download - no id") return nil, errors.New("can't download - no id")
} }
if o.contentType == emptyMimeType { if o.contentType == emptyMimeType {
return ioutil.NopCloser(bytes.NewReader([]byte{})), nil return io.NopCloser(bytes.NewReader([]byte{})), nil
} }
fs.FixRangeOption(options, o.size) fs.FixRangeOption(options, o.size)
resp, err := o.fs.rpc(ctx, "getFile", params{ resp, err := o.fs.rpc(ctx, "getFile", params{

View File

@ -19,8 +19,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os"
"path" "path"
"strconv" "strconv"
"strings" "strings"
@ -487,7 +487,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
// try loading service account credentials from env variable, then from a file // try loading service account credentials from env variable, then from a file
if opt.ServiceAccountCredentials == "" && opt.ServiceAccountFile != "" { if opt.ServiceAccountCredentials == "" && opt.ServiceAccountFile != "" {
loadedCreds, err := ioutil.ReadFile(env.ShellExpand(opt.ServiceAccountFile)) loadedCreds, err := os.ReadFile(env.ShellExpand(opt.ServiceAccountFile))
if err != nil { if err != nil {
return nil, fmt.Errorf("error opening service account credentials file: %w", err) return nil, fmt.Errorf("error opening service account credentials file: %w", err)
} }

View File

@ -3,7 +3,7 @@ package googlephotos
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"path" "path"
"testing" "testing"
@ -99,7 +99,7 @@ func TestIntegration(t *testing.T) {
t.Run("ObjectOpen", func(t *testing.T) { t.Run("ObjectOpen", func(t *testing.T) {
in, err := dstObj.Open(ctx) in, err := dstObj.Open(ctx)
require.NoError(t, err) require.NoError(t, err)
buf, err := ioutil.ReadAll(in) buf, err := io.ReadAll(in)
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, in.Close()) require.NoError(t, in.Close())
assert.True(t, len(buf) > 1000) assert.True(t, len(buf) > 1000)

View File

@ -5,7 +5,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"path" "path"
"time" "time"
@ -118,7 +117,7 @@ func (o *Object) updateHashes(ctx context.Context) error {
defer func() { defer func() {
_ = r.Close() _ = r.Close()
}() }()
if _, err = io.Copy(ioutil.Discard, r); err != nil { if _, err = io.Copy(io.Discard, r); err != nil {
fs.Infof(o, "update failed (copy): %v", err) fs.Infof(o, "update failed (copy): %v", err)
return err return err
} }

View File

@ -3,7 +3,7 @@ package http
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
@ -41,12 +41,12 @@ func prepareServer(t *testing.T) (configmap.Simple, func()) {
// verify the file path is correct, and also check which line endings // verify the file path is correct, and also check which line endings
// are used to get sizes right ("\n" except on Windows, but even there // are used to get sizes right ("\n" except on Windows, but even there
// we may have "\n" or "\r\n" depending on git crlf setting) // we may have "\n" or "\r\n" depending on git crlf setting)
fileList, err := ioutil.ReadDir(filesPath) fileList, err := os.ReadDir(filesPath)
require.NoError(t, err) require.NoError(t, err)
require.Greater(t, len(fileList), 0) require.Greater(t, len(fileList), 0)
for _, file := range fileList { for _, file := range fileList {
if !file.IsDir() { if !file.IsDir() {
data, _ := ioutil.ReadFile(filepath.Join(filesPath, file.Name())) data, _ := os.ReadFile(filepath.Join(filesPath, file.Name()))
if strings.HasSuffix(string(data), "\r\n") { if strings.HasSuffix(string(data), "\r\n") {
lineEndSize = 2 lineEndSize = 2
} }
@ -203,7 +203,7 @@ func TestOpen(t *testing.T) {
// Test normal read // Test normal read
fd, err := o.Open(context.Background()) fd, err := o.Open(context.Background())
require.NoError(t, err) require.NoError(t, err)
data, err := ioutil.ReadAll(fd) data, err := io.ReadAll(fd)
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, fd.Close()) require.NoError(t, fd.Close())
if lineEndSize == 2 { if lineEndSize == 2 {
@ -215,7 +215,7 @@ func TestOpen(t *testing.T) {
// Test with range request // Test with range request
fd, err = o.Open(context.Background(), &fs.RangeOption{Start: 1, End: 5}) fd, err = o.Open(context.Background(), &fs.RangeOption{Start: 1, End: 5})
require.NoError(t, err) require.NoError(t, err)
data, err = ioutil.ReadAll(fd) data, err = io.ReadAll(fd)
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, fd.Close()) require.NoError(t, fd.Close())
assert.Equal(t, "eetro", string(data)) assert.Equal(t, "eetro", string(data))

View File

@ -12,7 +12,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math/rand" "math/rand"
"net/http" "net/http"
"net/url" "net/url"
@ -822,7 +821,7 @@ func (f *Fs) allocatePathRaw(file string, absolute bool) string {
func grantTypeFilter(req *http.Request) { func grantTypeFilter(req *http.Request) {
if legacyTokenURL == req.URL.String() { if legacyTokenURL == req.URL.String() {
// read the entire body // read the entire body
refreshBody, err := ioutil.ReadAll(req.Body) refreshBody, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
return return
} }
@ -832,7 +831,7 @@ func grantTypeFilter(req *http.Request) {
refreshBody = []byte(strings.Replace(string(refreshBody), "grant_type=refresh_token", "grant_type=REFRESH_TOKEN", 1)) refreshBody = []byte(strings.Replace(string(refreshBody), "grant_type=refresh_token", "grant_type=REFRESH_TOKEN", 1))
// set the new ReadCloser (with a dummy Close()) // set the new ReadCloser (with a dummy Close())
req.Body = ioutil.NopCloser(bytes.NewReader(refreshBody)) req.Body = io.NopCloser(bytes.NewReader(refreshBody))
} }
} }
@ -1789,7 +1788,7 @@ func readMD5(in io.Reader, size, threshold int64) (md5sum string, out io.Reader,
var tempFile *os.File var tempFile *os.File
// create the cache file // create the cache file
tempFile, err = ioutil.TempFile("", cachePrefix) tempFile, err = os.CreateTemp("", cachePrefix)
if err != nil { if err != nil {
return return
} }
@ -1817,7 +1816,7 @@ func readMD5(in io.Reader, size, threshold int64) (md5sum string, out io.Reader,
} else { } else {
// that's a small file, just read it into memory // that's a small file, just read it into memory
var inData []byte var inData []byte
inData, err = ioutil.ReadAll(teeReader) inData, err = io.ReadAll(teeReader)
if err != nil { if err != nil {
return return
} }
@ -1914,7 +1913,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
// copy the already uploaded bytes into the trash :) // copy the already uploaded bytes into the trash :)
var result api.UploadResponse var result api.UploadResponse
_, err = io.CopyN(ioutil.Discard, in, response.ResumePos) _, err = io.CopyN(io.Discard, in, response.ResumePos)
if err != nil { if err != nil {
return err return err
} }

View File

@ -7,7 +7,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -646,7 +645,7 @@ func (f *Fs) readPrecision() (precision time.Duration) {
precision = time.Second precision = time.Second
// Create temporary file and test it // Create temporary file and test it
fd, err := ioutil.TempFile("", "rclone") fd, err := os.CreateTemp("", "rclone")
if err != nil { if err != nil {
// If failed return 1s // If failed return 1s
// fmt.Println("Failed to create temp file", err) // fmt.Println("Failed to create temp file", err)
@ -1073,7 +1072,7 @@ func (o *Object) openTranslatedLink(offset, limit int64) (lrc io.ReadCloser, err
if err != nil { if err != nil {
return nil, err return nil, err
} }
return readers.NewLimitedReadCloser(ioutil.NopCloser(strings.NewReader(linkdst[offset:])), limit), nil return readers.NewLimitedReadCloser(io.NopCloser(strings.NewReader(linkdst[offset:])), limit), nil
} }
// Open an object for read // Open an object for read

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -150,7 +150,7 @@ func TestSymlink(t *testing.T) {
// Check reading the object // Check reading the object
in, err := o.Open(ctx) in, err := o.Open(ctx)
require.NoError(t, err) require.NoError(t, err)
contents, err := ioutil.ReadAll(in) contents, err := io.ReadAll(in)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "file.txt", string(contents)) require.Equal(t, "file.txt", string(contents))
require.NoError(t, in.Close()) require.NoError(t, in.Close())
@ -158,7 +158,7 @@ func TestSymlink(t *testing.T) {
// Check reading the object with range // Check reading the object with range
in, err = o.Open(ctx, &fs.RangeOption{Start: 2, End: 5}) in, err = o.Open(ctx, &fs.RangeOption{Start: 2, End: 5})
require.NoError(t, err) require.NoError(t, err)
contents, err = ioutil.ReadAll(in) contents, err = io.ReadAll(in)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "file.txt"[2:5+1], string(contents)) require.Equal(t, "file.txt"[2:5+1], string(contents))
require.NoError(t, in.Close()) require.NoError(t, in.Close())

View File

@ -1,7 +1,6 @@
package local package local
import ( import (
"io/ioutil"
"os" "os"
"sync" "sync"
"testing" "testing"
@ -13,7 +12,7 @@ import (
// Check we can remove an open file // Check we can remove an open file
func TestRemove(t *testing.T) { func TestRemove(t *testing.T) {
fd, err := ioutil.TempFile("", "rclone-remove-test") fd, err := os.CreateTemp("", "rclone-remove-test")
require.NoError(t, err) require.NoError(t, err)
name := fd.Name() name := fd.Name()
defer func() { defer func() {

View File

@ -18,7 +18,6 @@ import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
@ -1660,7 +1659,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
// Attempt to put by calculating hash in memory // Attempt to put by calculating hash in memory
if trySpeedup && size <= int64(o.fs.opt.SpeedupMaxMem) { if trySpeedup && size <= int64(o.fs.opt.SpeedupMaxMem) {
fileBuf, err = ioutil.ReadAll(in) fileBuf, err = io.ReadAll(in)
if err != nil { if err != nil {
return err return err
} }
@ -1703,7 +1702,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
if size <= mrhash.Size { if size <= mrhash.Size {
// Optimize upload: skip extra request if data fits in the hash buffer. // Optimize upload: skip extra request if data fits in the hash buffer.
if fileBuf == nil { if fileBuf == nil {
fileBuf, err = ioutil.ReadAll(wrapIn) fileBuf, err = io.ReadAll(wrapIn)
} }
if fileHash == nil && err == nil { if fileHash == nil && err == nil {
fileHash = mrhash.Sum(fileBuf) fileHash = mrhash.Sum(fileBuf)
@ -2214,7 +2213,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
fs.Debugf(o, "Server returned full content instead of range") fs.Debugf(o, "Server returned full content instead of range")
if start > 0 { if start > 0 {
// Discard the beginning of the data // Discard the beginning of the data
_, err = io.CopyN(ioutil.Discard, wrapStream, start) _, err = io.CopyN(io.Discard, wrapStream, start)
if err != nil { if err != nil {
closeBody(res) closeBody(res)
return nil, err return nil, err

View File

@ -8,7 +8,6 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"path" "path"
"strings" "strings"
"sync" "sync"
@ -575,7 +574,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
} }
data = data[:limit] data = data[:limit]
} }
return ioutil.NopCloser(bytes.NewBuffer(data)), nil return io.NopCloser(bytes.NewBuffer(data)), nil
} }
// Update the object with the contents of the io.Reader, modTime and size // Update the object with the contents of the io.Reader, modTime and size
@ -583,7 +582,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
// The new object may have been created if an error is returned // The new object may have been created if an error is returned
func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error) { func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error) {
bucket, bucketPath := o.split() bucket, bucketPath := o.split()
data, err := ioutil.ReadAll(in) data, err := io.ReadAll(in)
if err != nil { if err != nil {
return fmt.Errorf("failed to update memory object: %w", err) return fmt.Errorf("failed to update memory object: %w", err)
} }

View File

@ -12,7 +12,6 @@ import (
"fmt" "fmt"
gohash "hash" gohash "hash"
"io" "io"
"io/ioutil"
"math/rand" "math/rand"
"net/http" "net/http"
"net/url" "net/url"
@ -972,7 +971,7 @@ func (o *Object) netStorageUploadRequest(ctx context.Context, in io.Reader, src
URL = o.fs.url(src.Remote()) URL = o.fs.url(src.Remote())
} }
if strings.HasSuffix(URL, ".rclonelink") { if strings.HasSuffix(URL, ".rclonelink") {
bits, err := ioutil.ReadAll(in) bits, err := io.ReadAll(in)
if err != nil { if err != nil {
return err return err
} }
@ -1058,7 +1057,7 @@ func (o *Object) netStorageDownloadRequest(ctx context.Context, options []fs.Ope
if strings.HasSuffix(URL, ".rclonelink") && o.target != "" { if strings.HasSuffix(URL, ".rclonelink") && o.target != "" {
fs.Infof(nil, "Converting a symlink to the rclonelink file on download %q", URL) fs.Infof(nil, "Converting a symlink to the rclonelink file on download %q", URL)
reader := strings.NewReader(o.target) reader := strings.NewReader(o.target)
readcloser := ioutil.NopCloser(reader) readcloser := io.NopCloser(reader)
return readcloser, nil return readcloser, nil
} }

View File

@ -15,7 +15,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -5148,7 +5147,7 @@ func (o *Object) uploadSinglepartPutObject(ctx context.Context, req *s3.PutObjec
// Can't upload zero length files like this for some reason // Can't upload zero length files like this for some reason
r.Body = bytes.NewReader([]byte{}) r.Body = bytes.NewReader([]byte{})
} else { } else {
r.SetStreamingBody(ioutil.NopCloser(in)) r.SetStreamingBody(io.NopCloser(in))
} }
r.SetContext(ctx) r.SetContext(ctx)
r.HTTPRequest.Header.Set("X-Amz-Content-Sha256", "UNSIGNED-PAYLOAD") r.HTTPRequest.Header.Set("X-Amz-Content-Sha256", "UNSIGNED-PAYLOAD")

View File

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -633,7 +632,7 @@ func (f *Fs) download(ctx context.Context, url string, size int64, options ...fs
}) })
if start > 0 { if start > 0 {
// We need to read and discard the beginning of the data... // We need to read and discard the beginning of the data...
_, err = io.CopyN(ioutil.Discard, resp.Body, start) _, err = io.CopyN(io.Discard, resp.Body, start)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -10,7 +10,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"path" "path"
"regexp" "regexp"
@ -783,7 +782,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
return nil, fmt.Errorf("couldn't read ssh agent signers: %w", err) return nil, fmt.Errorf("couldn't read ssh agent signers: %w", err)
} }
if keyFile != "" { if keyFile != "" {
pubBytes, err := ioutil.ReadFile(keyFile + ".pub") pubBytes, err := os.ReadFile(keyFile + ".pub")
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read public key file: %w", err) return nil, fmt.Errorf("failed to read public key file: %w", err)
} }
@ -812,7 +811,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
if keyFile != "" || opt.KeyPem != "" { if keyFile != "" || opt.KeyPem != "" {
var key []byte var key []byte
if opt.KeyPem == "" { if opt.KeyPem == "" {
key, err = ioutil.ReadFile(keyFile) key, err = os.ReadFile(keyFile)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read private key file: %w", err) return nil, fmt.Errorf("failed to read private key file: %w", err)
} }
@ -843,7 +842,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
// If a public key has been specified then use that // If a public key has been specified then use that
if pubkeyFile != "" { if pubkeyFile != "" {
certfile, err := ioutil.ReadFile(pubkeyFile) certfile, err := os.ReadFile(pubkeyFile)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to read cert file: %w", err) return nil, fmt.Errorf("unable to read cert file: %w", err)
} }

View File

@ -77,7 +77,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -479,7 +478,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to open timezone db: %w", err) return nil, fmt.Errorf("failed to open timezone db: %w", err)
} }
tzdata, err := ioutil.ReadAll(timezone) tzdata, err := io.ReadAll(timezone)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read timezone: %w", err) return nil, fmt.Errorf("failed to read timezone: %w", err)
} }

View File

@ -10,7 +10,6 @@ import (
"compress/gzip" "compress/gzip"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
pathpkg "path" pathpkg "path"
@ -119,7 +118,7 @@ func (f *vfsgen۰CompressedFile) Read(p []byte) (n int, err error) {
} }
if f.grPos < f.seekPos { if f.grPos < f.seekPos {
// Fast-forward. // Fast-forward.
_, err = io.CopyN(ioutil.Discard, f.gr, f.seekPos-f.grPos) _, err = io.CopyN(io.Discard, f.gr, f.seekPos-f.grPos)
if err != nil { if err != nil {
return 0, err return 0, err
} }

View File

@ -2,7 +2,7 @@ package sugarsync
import ( import (
"bytes" "bytes"
"io/ioutil" "io"
"net/http" "net/http"
"testing" "testing"
@ -48,7 +48,7 @@ func TestErrorHandler(t *testing.T) {
} { } {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
resp := http.Response{ resp := http.Response{
Body: ioutil.NopCloser(bytes.NewBufferString(test.body)), Body: io.NopCloser(bytes.NewBufferString(test.body)),
StatusCode: test.code, StatusCode: test.code,
Status: test.status, Status: test.status,
} }

View File

@ -6,7 +6,6 @@ import (
"context" "context"
"errors" "errors"
"io" "io"
"io/ioutil"
"testing" "testing"
"github.com/ncw/swift/v2" "github.com/ncw/swift/v2"
@ -136,7 +135,7 @@ func (f *Fs) testWithChunkFail(t *testing.T) {
buf := bytes.NewBufferString(contents[:errPosition]) buf := bytes.NewBufferString(contents[:errPosition])
errMessage := "potato" errMessage := "potato"
er := &readers.ErrorReader{Err: errors.New(errMessage)} er := &readers.ErrorReader{Err: errors.New(errMessage)}
in := ioutil.NopCloser(io.MultiReader(buf, er)) in := io.NopCloser(io.MultiReader(buf, er))
file.Size = contentSize file.Size = contentSize
obji := object.NewStaticObjectInfo(file.Path, file.ModTime, file.Size, true, nil, nil) obji := object.NewStaticObjectInfo(file.Path, file.ModTime, file.Size, true, nil, nil)

View File

@ -5,7 +5,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"sync" "sync"
"time" "time"
@ -87,7 +86,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err) errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)
if len(entries) > 1 { if len(entries) > 1 {
// Drain the input buffer to allow other uploads to continue // Drain the input buffer to allow other uploads to continue
_, _ = io.Copy(ioutil.Discard, readers[i]) _, _ = io.Copy(io.Discard, readers[i])
} }
} }
} else { } else {

View File

@ -7,7 +7,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"path" "path"
"path/filepath" "path/filepath"
"strings" "strings"
@ -501,7 +500,7 @@ func (f *Fs) put(ctx context.Context, in io.Reader, src fs.ObjectInfo, stream bo
errs[i] = fmt.Errorf("%s: %w", u.Name(), err) errs[i] = fmt.Errorf("%s: %w", u.Name(), err)
if len(upstreams) > 1 { if len(upstreams) > 1 {
// Drain the input buffer to allow other uploads to continue // Drain the input buffer to allow other uploads to continue
_, _ = io.Copy(ioutil.Discard, readers[i]) _, _ = io.Copy(io.Discard, readers[i])
} }
return return
} }

View File

@ -7,7 +7,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -239,7 +238,7 @@ func NewFs(ctx context.Context, name string, root string, config configmap.Mappe
func (f *Fs) decodeError(resp *http.Response, response interface{}) (err error) { func (f *Fs) decodeError(resp *http.Response, response interface{}) (err error) {
defer fs.CheckClose(resp.Body, &err) defer fs.CheckClose(resp.Body, &err)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View File

@ -7,7 +7,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -1219,7 +1218,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
if partialContent && resp.StatusCode == 200 { if partialContent && resp.StatusCode == 200 {
if start > 0 { if start > 0 {
// We need to read and discard the beginning of the data... // We need to read and discard the beginning of the data...
_, err = io.CopyN(ioutil.Discard, resp.Body, start) _, err = io.CopyN(io.Discard, resp.Body, start)
if err != nil { if err != nil {
if resp != nil { if resp != nil {
_ = resp.Body.Close() _ = resp.Body.Close()

View File

@ -9,7 +9,6 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@ -240,7 +239,7 @@ func buildWindowsResourceSyso(goarch string, versionTag string) string {
log.Printf("Failed to resolve path: %v", err) log.Printf("Failed to resolve path: %v", err)
return "" return ""
} }
err = ioutil.WriteFile(jsonPath, bs, 0644) err = os.WriteFile(jsonPath, bs, 0644)
if err != nil { if err != nil {
log.Printf("Failed to write %s: %v", jsonPath, err) log.Printf("Failed to write %s: %v", jsonPath, err)
return "" return ""
@ -476,7 +475,7 @@ func main() {
run("mkdir", "build") run("mkdir", "build")
} }
chdir("build") chdir("build")
err := ioutil.WriteFile("version.txt", []byte(fmt.Sprintf("rclone %s\n", version)), 0666) err := os.WriteFile("version.txt", []byte(fmt.Sprintf("rclone %s\n", version)), 0666)
if err != nil { if err != nil {
log.Fatalf("Couldn't write version.txt: %v", err) log.Fatalf("Couldn't write version.txt: %v", err)
} }

View File

@ -16,7 +16,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"net/http" "net/http"
"net/url" "net/url"
@ -168,7 +167,7 @@ func defaultBinDir() string {
// read the body or an error message // read the body or an error message
func readBody(in io.Reader) string { func readBody(in io.Reader) string {
data, err := ioutil.ReadAll(in) data, err := io.ReadAll(in)
if err != nil { if err != nil {
return fmt.Sprintf("Error reading body: %v", err.Error()) return fmt.Sprintf("Error reading body: %v", err.Error())
} }

View File

@ -5,7 +5,6 @@ import (
"bytes" "bytes"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@ -56,7 +55,7 @@ func main() {
log.Fatalf("Syntax: %s", os.Args[0]) log.Fatalf("Syntax: %s", os.Args[0])
} }
// v1.54.0 // v1.54.0
versionBytes, err := ioutil.ReadFile("VERSION") versionBytes, err := os.ReadFile("VERSION")
if err != nil { if err != nil {
log.Fatalf("Failed to read version: %v", err) log.Fatalf("Failed to read version: %v", err)
} }

View File

@ -5,7 +5,6 @@ package bilib
import ( import (
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
@ -106,7 +105,7 @@ func CopyDir(src string, dst string) (err error) {
return return
} }
entries, err := ioutil.ReadDir(src) entries, err := os.ReadDir(src)
if err != nil { if err != nil {
return return
} }
@ -122,7 +121,7 @@ func CopyDir(src string, dst string) (err error) {
} }
} else { } else {
// Skip symlinks. // Skip symlinks.
if entry.Mode()&os.ModeSymlink != 0 { if entry.Type()&os.ModeSymlink != 0 {
continue continue
} }

View File

@ -2,7 +2,7 @@ package bilib
import ( import (
"bytes" "bytes"
"io/ioutil" "os"
"sort" "sort"
"strconv" "strconv"
) )
@ -57,5 +57,5 @@ func SaveList(list []string, path string) error {
_, _ = buf.WriteString(strconv.Quote(s)) _, _ = buf.WriteString(strconv.Quote(s))
_ = buf.WriteByte('\n') _ = buf.WriteByte('\n')
} }
return ioutil.WriteFile(path, buf.Bytes(), PermSecure) return os.WriteFile(path, buf.Bytes(), PermSecure)
} }

View File

@ -10,7 +10,6 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os" "os"
"path" "path"
@ -303,7 +302,7 @@ func (b *bisyncTest) runTestCase(ctx context.Context, t *testing.T, testCase str
// Execute test scenario // Execute test scenario
scenFile := filepath.Join(b.testDir, "scenario.txt") scenFile := filepath.Join(b.testDir, "scenario.txt")
scenBuf, err := ioutil.ReadFile(scenFile) scenBuf, err := os.ReadFile(scenFile)
scenReplacer := b.newReplacer(false) scenReplacer := b.newReplacer(false)
require.NoError(b.t, err) require.NoError(b.t, err)
b.step = 0 b.step = 0
@ -903,8 +902,8 @@ func (b *bisyncTest) compareResults() int {
// save mangled logs so difference is easier on eyes // save mangled logs so difference is easier on eyes
goldenFile := filepath.Join(b.logDir, "mangled.golden.log") goldenFile := filepath.Join(b.logDir, "mangled.golden.log")
resultFile := filepath.Join(b.logDir, "mangled.result.log") resultFile := filepath.Join(b.logDir, "mangled.result.log")
require.NoError(b.t, ioutil.WriteFile(goldenFile, []byte(goldenText), bilib.PermSecure)) require.NoError(b.t, os.WriteFile(goldenFile, []byte(goldenText), bilib.PermSecure))
require.NoError(b.t, ioutil.WriteFile(resultFile, []byte(resultText), bilib.PermSecure)) require.NoError(b.t, os.WriteFile(resultFile, []byte(resultText), bilib.PermSecure))
} }
if goldenText == resultText { if goldenText == resultText {
@ -974,7 +973,7 @@ func (b *bisyncTest) storeGolden() {
goldName := b.toGolden(fileName) goldName := b.toGolden(fileName)
goldPath := filepath.Join(b.goldenDir, goldName) goldPath := filepath.Join(b.goldenDir, goldName)
err := ioutil.WriteFile(goldPath, []byte(text), bilib.PermSecure) err := os.WriteFile(goldPath, []byte(text), bilib.PermSecure)
assert.NoError(b.t, err, "writing golden file %s", goldName) assert.NoError(b.t, err, "writing golden file %s", goldName)
if goldName != fileName { if goldName != fileName {
@ -986,7 +985,7 @@ func (b *bisyncTest) storeGolden() {
// mangleResult prepares test logs or listings for comparison // mangleResult prepares test logs or listings for comparison
func (b *bisyncTest) mangleResult(dir, file string, golden bool) string { func (b *bisyncTest) mangleResult(dir, file string, golden bool) string {
buf, err := ioutil.ReadFile(filepath.Join(dir, file)) buf, err := os.ReadFile(filepath.Join(dir, file))
require.NoError(b.t, err) require.NoError(b.t, err)
text := string(buf) text := string(buf)
@ -1205,7 +1204,7 @@ func (b *bisyncTest) ensureDir(parent, dir string, optional bool) string {
} }
func (b *bisyncTest) listDir(dir string) (names []string) { func (b *bisyncTest) listDir(dir string) (names []string) {
files, err := ioutil.ReadDir(dir) files, err := os.ReadDir(dir)
require.NoError(b.t, err) require.NoError(b.t, err)
for _, file := range files { for _, file := range files {
names = append(names, filepath.Base(file.Name())) names = append(names, filepath.Base(file.Name()))

View File

@ -9,7 +9,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -198,7 +197,7 @@ func (opt *Options) applyFilters(ctx context.Context) (context.Context, error) {
_ = f.Close() _ = f.Close()
hashFile := filtersFile + ".md5" hashFile := filtersFile + ".md5"
wantHash, err := ioutil.ReadFile(hashFile) wantHash, err := os.ReadFile(hashFile)
if err != nil && !opt.Resync { if err != nil && !opt.Resync {
return ctx, fmt.Errorf("filters file md5 hash not found (must run --resync): %s", filtersFile) return ctx, fmt.Errorf("filters file md5 hash not found (must run --resync): %s", filtersFile)
} }
@ -209,7 +208,7 @@ func (opt *Options) applyFilters(ctx context.Context) (context.Context, error) {
if opt.Resync { if opt.Resync {
fs.Infof(nil, "Storing filters file hash to %s", hashFile) fs.Infof(nil, "Storing filters file hash to %s", hashFile)
if err := ioutil.WriteFile(hashFile, []byte(gotHash), bilib.PermSecure); err != nil { if err := os.WriteFile(hashFile, []byte(gotHash), bilib.PermSecure); err != nil {
return ctx, err return ctx, err
} }
} }

View File

@ -7,7 +7,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -81,7 +80,7 @@ func Bisync(ctx context.Context, fs1, fs2 fs.Fs, optArg *Options) (err error) {
} }
pidStr := []byte(strconv.Itoa(os.Getpid())) pidStr := []byte(strconv.Itoa(os.Getpid()))
if err = ioutil.WriteFile(lockFile, pidStr, bilib.PermSecure); err != nil { if err = os.WriteFile(lockFile, pidStr, bilib.PermSecure); err != nil {
return fmt.Errorf("cannot create lock file: %s: %w", lockFile, err) return fmt.Errorf("cannot create lock file: %s: %w", lockFile, err)
} }
fs.Debugf(nil, "Lock file created: %s", lockFile) fs.Debugf(nil, "Lock file created: %s", lockFile)

View File

@ -4,7 +4,6 @@ package cat
import ( import (
"context" "context"
"io" "io"
"io/ioutil"
"log" "log"
"os" "os"
"strings" "strings"
@ -77,7 +76,7 @@ Note that if offset is negative it will count from the end, so
fsrc := cmd.NewFsSrc(args) fsrc := cmd.NewFsSrc(args)
var w io.Writer = os.Stdout var w io.Writer = os.Stdout
if discard { if discard {
w = ioutil.Discard w = io.Discard
} }
cmd.Run(false, false, command, func() error { cmd.Run(false, false, command, func() error {
return operations.Cat(context.Background(), fsrc, w, offset, count) return operations.Cat(context.Background(), fsrc, w, offset, count)

View File

@ -1,7 +1,6 @@
package genautocomplete package genautocomplete
import ( import (
"io/ioutil"
"os" "os"
"testing" "testing"
@ -9,7 +8,7 @@ import (
) )
func TestCompletionBash(t *testing.T) { func TestCompletionBash(t *testing.T) {
tempFile, err := ioutil.TempFile("", "completion_bash") tempFile, err := os.CreateTemp("", "completion_bash")
assert.NoError(t, err) assert.NoError(t, err)
defer func() { defer func() {
_ = tempFile.Close() _ = tempFile.Close()
@ -18,14 +17,14 @@ func TestCompletionBash(t *testing.T) {
bashCommandDefinition.Run(bashCommandDefinition, []string{tempFile.Name()}) bashCommandDefinition.Run(bashCommandDefinition, []string{tempFile.Name()})
bs, err := ioutil.ReadFile(tempFile.Name()) bs, err := os.ReadFile(tempFile.Name())
assert.NoError(t, err) assert.NoError(t, err)
assert.NotEmpty(t, string(bs)) assert.NotEmpty(t, string(bs))
} }
func TestCompletionBashStdout(t *testing.T) { func TestCompletionBashStdout(t *testing.T) {
originalStdout := os.Stdout originalStdout := os.Stdout
tempFile, err := ioutil.TempFile("", "completion_zsh") tempFile, err := os.CreateTemp("", "completion_zsh")
assert.NoError(t, err) assert.NoError(t, err)
defer func() { defer func() {
_ = tempFile.Close() _ = tempFile.Close()
@ -37,13 +36,13 @@ func TestCompletionBashStdout(t *testing.T) {
bashCommandDefinition.Run(bashCommandDefinition, []string{"-"}) bashCommandDefinition.Run(bashCommandDefinition, []string{"-"})
output, err := ioutil.ReadFile(tempFile.Name()) output, err := os.ReadFile(tempFile.Name())
assert.NoError(t, err) assert.NoError(t, err)
assert.NotEmpty(t, string(output)) assert.NotEmpty(t, string(output))
} }
func TestCompletionZsh(t *testing.T) { func TestCompletionZsh(t *testing.T) {
tempFile, err := ioutil.TempFile("", "completion_zsh") tempFile, err := os.CreateTemp("", "completion_zsh")
assert.NoError(t, err) assert.NoError(t, err)
defer func() { defer func() {
_ = tempFile.Close() _ = tempFile.Close()
@ -52,14 +51,14 @@ func TestCompletionZsh(t *testing.T) {
zshCommandDefinition.Run(zshCommandDefinition, []string{tempFile.Name()}) zshCommandDefinition.Run(zshCommandDefinition, []string{tempFile.Name()})
bs, err := ioutil.ReadFile(tempFile.Name()) bs, err := os.ReadFile(tempFile.Name())
assert.NoError(t, err) assert.NoError(t, err)
assert.NotEmpty(t, string(bs)) assert.NotEmpty(t, string(bs))
} }
func TestCompletionZshStdout(t *testing.T) { func TestCompletionZshStdout(t *testing.T) {
originalStdout := os.Stdout originalStdout := os.Stdout
tempFile, err := ioutil.TempFile("", "completion_zsh") tempFile, err := os.CreateTemp("", "completion_zsh")
assert.NoError(t, err) assert.NoError(t, err)
defer func() { defer func() {
_ = tempFile.Close() _ = tempFile.Close()
@ -70,13 +69,13 @@ func TestCompletionZshStdout(t *testing.T) {
defer func() { os.Stdout = originalStdout }() defer func() { os.Stdout = originalStdout }()
zshCommandDefinition.Run(zshCommandDefinition, []string{"-"}) zshCommandDefinition.Run(zshCommandDefinition, []string{"-"})
output, err := ioutil.ReadFile(tempFile.Name()) output, err := os.ReadFile(tempFile.Name())
assert.NoError(t, err) assert.NoError(t, err)
assert.NotEmpty(t, string(output)) assert.NotEmpty(t, string(output))
} }
func TestCompletionFish(t *testing.T) { func TestCompletionFish(t *testing.T) {
tempFile, err := ioutil.TempFile("", "completion_fish") tempFile, err := os.CreateTemp("", "completion_fish")
assert.NoError(t, err) assert.NoError(t, err)
defer func() { defer func() {
_ = tempFile.Close() _ = tempFile.Close()
@ -85,14 +84,14 @@ func TestCompletionFish(t *testing.T) {
fishCommandDefinition.Run(fishCommandDefinition, []string{tempFile.Name()}) fishCommandDefinition.Run(fishCommandDefinition, []string{tempFile.Name()})
bs, err := ioutil.ReadFile(tempFile.Name()) bs, err := os.ReadFile(tempFile.Name())
assert.NoError(t, err) assert.NoError(t, err)
assert.NotEmpty(t, string(bs)) assert.NotEmpty(t, string(bs))
} }
func TestCompletionFishStdout(t *testing.T) { func TestCompletionFishStdout(t *testing.T) {
originalStdout := os.Stdout originalStdout := os.Stdout
tempFile, err := ioutil.TempFile("", "completion_zsh") tempFile, err := os.CreateTemp("", "completion_zsh")
assert.NoError(t, err) assert.NoError(t, err)
defer func() { defer func() {
_ = tempFile.Close() _ = tempFile.Close()
@ -104,7 +103,7 @@ func TestCompletionFishStdout(t *testing.T) {
fishCommandDefinition.Run(fishCommandDefinition, []string{"-"}) fishCommandDefinition.Run(fishCommandDefinition, []string{"-"})
output, err := ioutil.ReadFile(tempFile.Name()) output, err := os.ReadFile(tempFile.Name())
assert.NoError(t, err) assert.NoError(t, err)
assert.NotEmpty(t, string(output)) assert.NotEmpty(t, string(output))
} }

View File

@ -3,7 +3,6 @@ package gendocs
import ( import (
"bytes" "bytes"
"io/ioutil"
"log" "log"
"os" "os"
"path" "path"
@ -71,7 +70,7 @@ rclone.org website.`,
if err != nil { if err != nil {
return err return err
} }
err = ioutil.WriteFile(filepath.Join(root, "flags.md"), buf.Bytes(), 0777) err = os.WriteFile(filepath.Join(root, "flags.md"), buf.Bytes(), 0777)
if err != nil { if err != nil {
return err return err
} }
@ -129,7 +128,7 @@ rclone.org website.`,
return err return err
} }
if !info.IsDir() { if !info.IsDir() {
b, err := ioutil.ReadFile(path) b, err := os.ReadFile(path)
if err != nil { if err != nil {
return err return err
} }
@ -140,7 +139,7 @@ See the [global flags page](/flags/) for global options not listed here.
### SEE ALSO`, 1) ### SEE ALSO`, 1)
// outdent all the titles by one // outdent all the titles by one
doc = outdentTitle.ReplaceAllString(doc, `$1`) doc = outdentTitle.ReplaceAllString(doc, `$1`)
err = ioutil.WriteFile(path, []byte(doc), 0777) err = os.WriteFile(path, []byte(doc), 0777)
if err != nil { if err != nil {
return err return err
} }

View File

@ -8,7 +8,6 @@ import (
"bytes" "bytes"
"flag" "flag"
"io" "io"
"io/ioutil"
"log" "log"
"math/rand" "math/rand"
"os" "os"
@ -60,11 +59,11 @@ func randomSeekTest(size int64, in1, in2 *os.File, file1, file2 string) {
if !bytes.Equal(buf1, buf2) { if !bytes.Equal(buf1, buf2) {
log.Printf("Dumping different blocks") log.Printf("Dumping different blocks")
err = ioutil.WriteFile("/tmp/z1", buf1, 0777) err = os.WriteFile("/tmp/z1", buf1, 0777)
if err != nil { if err != nil {
log.Fatalf("Failed to write /tmp/z1: %v", err) log.Fatalf("Failed to write /tmp/z1: %v", err)
} }
err = ioutil.WriteFile("/tmp/z2", buf2, 0777) err = os.WriteFile("/tmp/z2", buf2, 0777)
if err != nil { if err != nil {
log.Fatalf("Failed to write /tmp/z2: %v", err) log.Fatalf("Failed to write /tmp/z2: %v", err)
} }

View File

@ -2,7 +2,6 @@ package mountlib_test
import ( import (
"context" "context"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -36,7 +35,7 @@ func TestRc(t *testing.T) {
assert.NotNil(t, getMountTypes) assert.NotNil(t, getMountTypes)
localDir := t.TempDir() localDir := t.TempDir()
err := ioutil.WriteFile(filepath.Join(localDir, "file.txt"), []byte("hello"), 0666) err := os.WriteFile(filepath.Join(localDir, "file.txt"), []byte("hello"), 0666)
require.NoError(t, err) require.NoError(t, err)
mountPoint := t.TempDir() mountPoint := t.TempDir()

View File

@ -7,7 +7,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"os" "os"
"strings" "strings"
@ -204,7 +204,7 @@ func doCall(ctx context.Context, path string, in rc.Params) (out rc.Params, err
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
var body []byte var body []byte
body, err = ioutil.ReadAll(resp.Body) body, err = io.ReadAll(resp.Body)
var bodyString string var bodyString string
if err == nil { if err == nil {
bodyString = string(body) bodyString = string(body)

View File

@ -14,7 +14,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"net/http" "net/http"
"os" "os"
@ -227,7 +226,7 @@ func InstallUpdate(ctx context.Context, opt *Options) error {
} }
func installPackage(ctx context.Context, beta bool, version, siteURL, packageFormat string) error { func installPackage(ctx context.Context, beta bool, version, siteURL, packageFormat string) error {
tempFile, err := ioutil.TempFile("", "rclone.*."+packageFormat) tempFile, err := os.CreateTemp("", "rclone.*."+packageFormat)
if err != nil { if err != nil {
return fmt.Errorf("unable to write temporary package: %w", err) return fmt.Errorf("unable to write temporary package: %w", err)
} }
@ -357,7 +356,7 @@ func downloadUpdate(ctx context.Context, beta bool, version, siteURL, newFile, p
} }
if packageFormat == "deb" || packageFormat == "rpm" { if packageFormat == "deb" || packageFormat == "rpm" {
if err := ioutil.WriteFile(newFile, archiveBuf, 0644); err != nil { if err := os.WriteFile(newFile, archiveBuf, 0644); err != nil {
return fmt.Errorf("cannot write temporary .%s: %w", packageFormat, err) return fmt.Errorf("cannot write temporary .%s: %w", packageFormat, err)
} }
return nil return nil
@ -471,5 +470,5 @@ func downloadFile(ctx context.Context, url string) ([]byte, error) {
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed with %s downloading %s", resp.Status, url) return nil, fmt.Errorf("failed with %s downloading %s", resp.Status, url)
} }
return ioutil.ReadAll(resp.Body) return io.ReadAll(resp.Body)
} }

View File

@ -5,7 +5,6 @@ package selfupdate
import ( import (
"context" "context"
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -86,7 +85,7 @@ func TestInstallOnLinux(t *testing.T) {
assert.NoError(t, InstallUpdate(ctx, &Options{Beta: true, Output: path, Version: fs.Version})) assert.NoError(t, InstallUpdate(ctx, &Options{Beta: true, Output: path, Version: fs.Version}))
// Must fail on non-writable file // Must fail on non-writable file
assert.NoError(t, ioutil.WriteFile(path, []byte("test"), 0644)) assert.NoError(t, os.WriteFile(path, []byte("test"), 0644))
assert.NoError(t, os.Chmod(path, 0000)) assert.NoError(t, os.Chmod(path, 0000))
err = (InstallUpdate(ctx, &Options{Beta: true, Output: path})) err = (InstallUpdate(ctx, &Options{Beta: true, Output: path}))
assert.Error(t, err) assert.Error(t, err)
@ -101,7 +100,7 @@ func TestInstallOnLinux(t *testing.T) {
assert.Equal(t, os.FileMode(0644), info.Mode().Perm()) assert.Equal(t, os.FileMode(0644), info.Mode().Perm())
// Must remove temporary files // Must remove temporary files
files, err := ioutil.ReadDir(testDir) files, err := os.ReadDir(testDir)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 1, len(files)) assert.Equal(t, 1, len(files))
@ -141,7 +140,7 @@ func TestRenameOnWindows(t *testing.T) {
// Must not create temporary files when target doesn't exist // Must not create temporary files when target doesn't exist
assert.NoError(t, InstallUpdate(ctx, &Options{Beta: true, Output: path})) assert.NoError(t, InstallUpdate(ctx, &Options{Beta: true, Output: path}))
files, err := ioutil.ReadDir(testDir) files, err := os.ReadDir(testDir)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 1, len(files)) assert.Equal(t, 1, len(files))
@ -152,7 +151,7 @@ func TestRenameOnWindows(t *testing.T) {
assert.NoError(t, cmdWait.Start()) assert.NoError(t, cmdWait.Start())
assert.NoError(t, InstallUpdate(ctx, &Options{Beta: false, Output: path})) assert.NoError(t, InstallUpdate(ctx, &Options{Beta: false, Output: path}))
files, err = ioutil.ReadDir(testDir) files, err = os.ReadDir(testDir)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 2, len(files)) assert.Equal(t, 2, len(files))
@ -189,7 +188,7 @@ func TestRenameOnWindows(t *testing.T) {
// Updating when the "old" executable is running must produce a random "old" file // Updating when the "old" executable is running must produce a random "old" file
assert.NoError(t, InstallUpdate(ctx, &Options{Beta: true, Output: path})) assert.NoError(t, InstallUpdate(ctx, &Options{Beta: true, Output: path}))
files, err = ioutil.ReadDir(testDir) files, err = os.ReadDir(testDir)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 3, len(files)) assert.Equal(t, 3, len(files))

View File

@ -9,7 +9,6 @@ import (
"compress/gzip" "compress/gzip"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
pathpkg "path" pathpkg "path"
@ -152,7 +151,7 @@ func (f *vfsgen۰CompressedFile) Read(p []byte) (n int, err error) {
} }
if f.grPos < f.seekPos { if f.grPos < f.seekPos {
// Fast-forward. // Fast-forward.
_, err = io.CopyN(ioutil.Discard, f.gr, f.seekPos-f.grPos) _, err = io.CopyN(io.Discard, f.gr, f.seekPos-f.grPos)
if err != nil { if err != nil {
return 0, err return 0, err
} }

View File

@ -6,7 +6,7 @@ package data
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"text/template" "text/template"
"github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs"
@ -21,7 +21,7 @@ func GetTemplate() (tpl *template.Template, err error) {
defer fs.CheckClose(templateFile, &err) defer fs.CheckClose(templateFile, &err)
templateBytes, err := ioutil.ReadAll(templateFile) templateBytes, err := io.ReadAll(templateFile)
if err != nil { if err != nil {
return nil, fmt.Errorf("get template read: %w", err) return nil, fmt.Errorf("get template read: %w", err)
} }

View File

@ -5,7 +5,7 @@ import (
"context" "context"
"fmt" "fmt"
"html" "html"
"io/ioutil" "io"
"net/http" "net/http"
"os" "os"
"strings" "strings"
@ -60,7 +60,7 @@ func TestRootSCPD(t *testing.T) {
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
require.NoError(t, err) require.NoError(t, err)
// Make sure that the SCPD contains a CDS service. // Make sure that the SCPD contains a CDS service.
require.Contains(t, string(body), require.Contains(t, string(body),
@ -80,7 +80,7 @@ func TestServeContent(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
defer fs.CheckClose(resp.Body, &err) defer fs.CheckClose(resp.Body, &err)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
actualContents, err := ioutil.ReadAll(resp.Body) actualContents, err := io.ReadAll(resp.Body)
assert.NoError(t, err) assert.NoError(t, err)
// Now compare the contents with the golden file. // Now compare the contents with the golden file.
@ -90,7 +90,7 @@ func TestServeContent(t *testing.T) {
goldenReader, err := goldenFile.Open(os.O_RDONLY) goldenReader, err := goldenFile.Open(os.O_RDONLY)
assert.NoError(t, err) assert.NoError(t, err)
defer fs.CheckClose(goldenReader, &err) defer fs.CheckClose(goldenReader, &err)
goldenContents, err := ioutil.ReadAll(goldenReader) goldenContents, err := io.ReadAll(goldenReader)
assert.NoError(t, err) assert.NoError(t, err)
require.Equal(t, goldenContents, actualContents) require.Equal(t, goldenContents, actualContents)
@ -119,7 +119,7 @@ func TestContentDirectoryBrowseMetadata(t *testing.T) {
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
require.NoError(t, err) require.NoError(t, err)
// should contain an appropriate URN // should contain an appropriate URN
require.Contains(t, string(body), "urn:schemas-upnp-org:service:ContentDirectory:1") require.Contains(t, string(body), "urn:schemas-upnp-org:service:ContentDirectory:1")
@ -145,7 +145,7 @@ func TestMediaReceiverRegistrarService(t *testing.T) {
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
require.NoError(t, err) require.NoError(t, err)
require.Contains(t, string(body), "<RegistrationRespMsg>") require.Contains(t, string(body), "<RegistrationRespMsg>")
} }
@ -173,7 +173,7 @@ func TestContentDirectoryBrowseDirectChildren(t *testing.T) {
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
require.NoError(t, err) require.NoError(t, err)
// expect video.mp4, video.srt, video.en.srt URLs to be in the DIDL // expect video.mp4, video.srt, video.en.srt URLs to be in the DIDL
require.Contains(t, string(body), "/r/video.mp4") require.Contains(t, string(body), "/r/video.mp4")
@ -201,7 +201,7 @@ func TestContentDirectoryBrowseDirectChildren(t *testing.T) {
resp, err = http.DefaultClient.Do(req) resp, err = http.DefaultClient.Do(req)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
body, err = ioutil.ReadAll(resp.Body) body, err = io.ReadAll(resp.Body)
require.NoError(t, err) require.NoError(t, err)
// expect video.mp4, video.srt, URLs to be in the DIDL // expect video.mp4, video.srt, URLs to be in the DIDL
require.Contains(t, string(body), "/r/subdir/video.mp4") require.Contains(t, string(body), "/r/subdir/video.mp4")

View File

@ -8,7 +8,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -280,7 +280,7 @@ func (a *APIClient) request(path string, in, out interface{}, wantErr bool) {
} }
assert.Equal(t, wantStatus, res.StatusCode) assert.Equal(t, wantStatus, res.StatusCode)
dataOut, err = ioutil.ReadAll(res.Body) dataOut, err = io.ReadAll(res.Body)
require.NoError(t, err) require.NoError(t, err)
err = res.Body.Close() err = res.Body.Close()
require.NoError(t, err) require.NoError(t, err)
@ -389,11 +389,11 @@ func testMountAPI(t *testing.T, sockAddr string) {
assert.Contains(t, res, "volume is in use") assert.Contains(t, res, "volume is in use")
text := []byte("banana") text := []byte("banana")
err = ioutil.WriteFile(filepath.Join(mount1, "txt"), text, 0644) err = os.WriteFile(filepath.Join(mount1, "txt"), text, 0644)
assert.NoError(t, err) assert.NoError(t, err)
time.Sleep(tempDelay) time.Sleep(tempDelay)
text2, err := ioutil.ReadFile(filepath.Join(path1, "txt")) text2, err := os.ReadFile(filepath.Join(path1, "txt"))
assert.NoError(t, err) assert.NoError(t, err)
if runtime.GOOS != "windows" { if runtime.GOOS != "windows" {
// this check sometimes fails on windows - ignore // this check sometimes fails on windows - ignore

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"math/rand" "math/rand"
"os" "os"
"path/filepath" "path/filepath"
@ -329,7 +328,7 @@ func (drv *Driver) saveState() error {
ctx := context.Background() ctx := context.Background()
retries := fs.GetConfig(ctx).LowLevelRetries retries := fs.GetConfig(ctx).LowLevelRetries
for i := 0; i <= retries; i++ { for i := 0; i <= retries; i++ {
err = ioutil.WriteFile(drv.statePath, data, 0600) err = os.WriteFile(drv.statePath, data, 0600)
if err == nil { if err == nil {
return nil return nil
} }
@ -342,7 +341,7 @@ func (drv *Driver) saveState() error {
func (drv *Driver) restoreState(ctx context.Context) error { func (drv *Driver) restoreState(ctx context.Context) error {
fs.Debugf(nil, "Restore state from %s", drv.statePath) fs.Debugf(nil, "Restore state from %s", drv.statePath)
data, err := ioutil.ReadFile(drv.statePath) data, err := os.ReadFile(drv.statePath)
if os.IsNotExist(err) { if os.IsNotExist(err) {
return nil return nil
} }

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"io/ioutil"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -93,7 +92,7 @@ func writeSpecFile(addr, proto, specDir string) (string, error) {
} }
specFile := filepath.Join(specDir, "rclone.spec") specFile := filepath.Join(specDir, "rclone.spec")
url := fmt.Sprintf("%s://%s", proto, addr) url := fmt.Sprintf("%s://%s", proto, addr)
if err := ioutil.WriteFile(specFile, []byte(url), 0644); err != nil { if err := os.WriteFile(specFile, []byte(url), 0644); err != nil {
return "", err return "", err
} }
fs.Debugf(nil, "Plugin spec has been written to %s", specFile) fs.Debugf(nil, "Plugin spec has been written to %s", specFile)

View File

@ -10,7 +10,6 @@ import (
"compress/gzip" "compress/gzip"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
pathpkg "path" pathpkg "path"
@ -112,7 +111,7 @@ func (f *vfsgen۰CompressedFile) Read(p []byte) (n int, err error) {
} }
if f.grPos < f.seekPos { if f.grPos < f.seekPos {
// Fast-forward. // Fast-forward.
_, err = io.CopyN(ioutil.Discard, f.gr, f.seekPos-f.grPos) _, err = io.CopyN(io.Discard, f.gr, f.seekPos-f.grPos)
if err != nil { if err != nil {
return 0, err return 0, err
} }

View File

@ -7,7 +7,8 @@ package data
import ( import (
"fmt" "fmt"
"html/template" "html/template"
"io/ioutil" "io"
"os"
"time" "time"
"github.com/spf13/pflag" "github.com/spf13/pflag"
@ -70,7 +71,7 @@ func GetTemplate(tmpl string) (tpl *template.Template, err error) {
defer fs.CheckClose(templateFile, &err) defer fs.CheckClose(templateFile, &err)
templateBytes, err := ioutil.ReadAll(templateFile) templateBytes, err := io.ReadAll(templateFile)
if err != nil { if err != nil {
return nil, fmt.Errorf("get template read: %w", err) return nil, fmt.Errorf("get template read: %w", err)
} }
@ -78,7 +79,7 @@ func GetTemplate(tmpl string) (tpl *template.Template, err error) {
templateString = string(templateBytes) templateString = string(templateBytes)
} else { } else {
templateFile, err := ioutil.ReadFile(tmpl) templateFile, err := os.ReadFile(tmpl)
if err != nil { if err != nil {
return nil, fmt.Errorf("get template open: %w", err) return nil, fmt.Errorf("get template open: %w", err)
} }

View File

@ -3,8 +3,9 @@ package http
import ( import (
"context" "context"
"flag" "flag"
"io/ioutil" "io"
"net/http" "net/http"
"os"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -91,10 +92,10 @@ func TestInit(t *testing.T) {
func checkGolden(t *testing.T, fileName string, got []byte) { func checkGolden(t *testing.T, fileName string, got []byte) {
if *updateGolden { if *updateGolden {
t.Logf("Updating golden file %q", fileName) t.Logf("Updating golden file %q", fileName)
err := ioutil.WriteFile(fileName, got, 0666) err := os.WriteFile(fileName, got, 0666)
require.NoError(t, err) require.NoError(t, err)
} else { } else {
want, err := ioutil.ReadFile(fileName) want, err := os.ReadFile(fileName)
require.NoError(t, err) require.NoError(t, err)
wants := strings.Split(string(want), "\n") wants := strings.Split(string(want), "\n")
gots := strings.Split(string(got), "\n") gots := strings.Split(string(got), "\n")
@ -210,7 +211,7 @@ func TestGET(t *testing.T) {
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, test.Status, resp.StatusCode, test.Golden) assert.Equal(t, test.Status, resp.StatusCode, test.Golden)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
require.NoError(t, err) require.NoError(t, err)
// Check we got a Last-Modified header and that it is a valid date // Check we got a Last-Modified header and that it is a valid date

View File

@ -10,10 +10,10 @@ import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"html/template" "html/template"
"io/ioutil"
"log" "log"
"net" "net"
"net/http" "net/http"
"os"
"strings" "strings"
"time" "time"
@ -315,7 +315,7 @@ func NewServer(handler http.Handler, opt *Options) *Server {
log.Fatalf("Can't use --client-ca without --cert and --key") log.Fatalf("Can't use --client-ca without --cert and --key")
} }
certpool := x509.NewCertPool() certpool := x509.NewCertPool()
pem, err := ioutil.ReadFile(s.Opt.ClientCA) pem, err := os.ReadFile(s.Opt.ClientCA)
if err != nil { if err != nil {
log.Fatalf("Failed to read client certificate authority: %v", err) log.Fatalf("Failed to read client certificate authority: %v", err)
} }

View File

@ -17,7 +17,6 @@ import (
"encoding/pem" "encoding/pem"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
@ -311,7 +310,7 @@ func (s *server) Close() {
} }
func loadPrivateKey(keyPath string) (ssh.Signer, error) { func loadPrivateKey(keyPath string) (ssh.Signer, error) {
privateBytes, err := ioutil.ReadFile(keyPath) privateBytes, err := os.ReadFile(keyPath)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to load private key: %w", err) return nil, fmt.Errorf("failed to load private key: %w", err)
} }
@ -326,7 +325,7 @@ func loadPrivateKey(keyPath string) (ssh.Signer, error) {
// the public key of a received connection // the public key of a received connection
// with the entries in the authorized_keys file. // with the entries in the authorized_keys file.
func loadAuthorizedKeys(authorizedKeysPath string) (authorizedKeysMap map[string]struct{}, err error) { func loadAuthorizedKeys(authorizedKeysPath string) (authorizedKeysMap map[string]struct{}, err error) {
authorizedKeysBytes, err := ioutil.ReadFile(authorizedKeysPath) authorizedKeysBytes, err := os.ReadFile(authorizedKeysPath)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to load authorized keys: %w", err) return nil, fmt.Errorf("failed to load authorized keys: %w", err)
} }
@ -369,7 +368,7 @@ func makeRSASSHKeyPair(bits int, pubKeyPath, privateKeyPath string) (err error)
if err != nil { if err != nil {
return err return err
} }
return ioutil.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644) return os.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644)
} }
// makeECDSASSHKeyPair make a pair of public and private keys for ECDSA SSH access. // makeECDSASSHKeyPair make a pair of public and private keys for ECDSA SSH access.
@ -401,7 +400,7 @@ func makeECDSASSHKeyPair(pubKeyPath, privateKeyPath string) (err error) {
if err != nil { if err != nil {
return err return err
} }
return ioutil.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644) return os.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644)
} }
// makeEd25519SSHKeyPair make a pair of public and private keys for Ed25519 SSH access. // makeEd25519SSHKeyPair make a pair of public and private keys for Ed25519 SSH access.
@ -433,5 +432,5 @@ func makeEd25519SSHKeyPair(pubKeyPath, privateKeyPath string) (err error) {
if err != nil { if err != nil {
return err return err
} }
return ioutil.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644) return os.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644)
} }

View File

@ -11,7 +11,7 @@ package webdav
import ( import (
"context" "context"
"flag" "flag"
"io/ioutil" "io"
"net/http" "net/http"
"os" "os"
"strings" "strings"
@ -134,10 +134,10 @@ func TestHTTPFunction(t *testing.T) {
func checkGolden(t *testing.T, fileName string, got []byte) { func checkGolden(t *testing.T, fileName string, got []byte) {
if *updateGolden { if *updateGolden {
t.Logf("Updating golden file %q", fileName) t.Logf("Updating golden file %q", fileName)
err := ioutil.WriteFile(fileName, got, 0666) err := os.WriteFile(fileName, got, 0666)
require.NoError(t, err) require.NoError(t, err)
} else { } else {
want, err := ioutil.ReadFile(fileName) want, err := os.ReadFile(fileName)
require.NoError(t, err, "problem") require.NoError(t, err, "problem")
wants := strings.Split(string(want), "\n") wants := strings.Split(string(want), "\n")
gots := strings.Split(string(got), "\n") gots := strings.Split(string(got), "\n")
@ -253,7 +253,7 @@ func HelpTestGET(t *testing.T, testURL string) {
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, test.Status, resp.StatusCode, test.Golden) assert.Equal(t, test.Status, resp.StatusCode, test.Golden)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
require.NoError(t, err) require.NoError(t, err)
checkGolden(t, test.Golden, body) checkGolden(t, test.Golden, body)

View File

@ -4,7 +4,7 @@ package version
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"time" "time"
@ -95,7 +95,7 @@ func GetVersion(url string) (v *semver.Version, vs string, date time.Time, err e
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return v, vs, date, errors.New(resp.Status) return v, vs, date, errors.New(resp.Status)
} }
bodyBytes, err := ioutil.ReadAll(resp.Body) bodyBytes, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return v, vs, date, err return v, vs, date, err
} }

View File

@ -1,7 +1,6 @@
package version package version
import ( import (
"io/ioutil"
"os" "os"
"runtime" "runtime"
"testing" "testing"
@ -13,7 +12,7 @@ import (
func TestVersionWorksWithoutAccessibleConfigFile(t *testing.T) { func TestVersionWorksWithoutAccessibleConfigFile(t *testing.T) {
// create temp config file // create temp config file
tempFile, err := ioutil.TempFile("", "unreadable_config.conf") tempFile, err := os.CreateTemp("", "unreadable_config.conf")
assert.NoError(t, err) assert.NoError(t, err)
path := tempFile.Name() path := tempFile.Name()
defer func() { defer func() {

View File

@ -6,7 +6,6 @@
package cmdtest package cmdtest
import ( import (
"io/ioutil"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@ -121,7 +120,7 @@ func removeTestEnvironment(t *testing.T) {
// createTestFile creates the file testFolder/name // createTestFile creates the file testFolder/name
func createTestFile(name string, t *testing.T) string { func createTestFile(name string, t *testing.T) string {
err := ioutil.WriteFile(testFolder+"/"+name, []byte("content_of_"+name), 0666) err := os.WriteFile(testFolder+"/"+name, []byte("content_of_"+name), 0666)
require.NoError(t, err) require.NoError(t, err)
return testFolder + "/" + name return testFolder + "/" + name
} }

View File

@ -5,7 +5,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"strings" "strings"
"testing" "testing"
"unicode/utf8" "unicode/utf8"
@ -29,7 +28,7 @@ var (
func TestNewAccountSizeName(t *testing.T) { func TestNewAccountSizeName(t *testing.T) {
ctx := context.Background() ctx := context.Background()
in := ioutil.NopCloser(bytes.NewBuffer([]byte{1})) in := io.NopCloser(bytes.NewBuffer([]byte{1}))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(context.Background(), stats, in, 1, "test") acc := newAccountSizeName(context.Background(), stats, in, 1, "test")
assert.Equal(t, in, acc.in) assert.Equal(t, in, acc.in)
@ -44,7 +43,7 @@ func TestNewAccountSizeName(t *testing.T) {
func TestAccountWithBuffer(t *testing.T) { func TestAccountWithBuffer(t *testing.T) {
ctx := context.Background() ctx := context.Background()
in := ioutil.NopCloser(bytes.NewBuffer([]byte{1})) in := io.NopCloser(bytes.NewBuffer([]byte{1}))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(ctx, stats, in, -1, "test") acc := newAccountSizeName(ctx, stats, in, -1, "test")
@ -68,7 +67,7 @@ func TestAccountGetUpdateReader(t *testing.T) {
ctx := context.Background() ctx := context.Background()
test := func(doClose bool) func(t *testing.T) { test := func(doClose bool) func(t *testing.T) {
return func(t *testing.T) { return func(t *testing.T) {
in := ioutil.NopCloser(bytes.NewBuffer([]byte{1})) in := io.NopCloser(bytes.NewBuffer([]byte{1}))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(ctx, stats, in, 1, "test") acc := newAccountSizeName(ctx, stats, in, 1, "test")
@ -80,7 +79,7 @@ func TestAccountGetUpdateReader(t *testing.T) {
require.NoError(t, acc.Close()) require.NoError(t, acc.Close())
} }
in2 := ioutil.NopCloser(bytes.NewBuffer([]byte{1})) in2 := io.NopCloser(bytes.NewBuffer([]byte{1}))
acc.UpdateReader(ctx, in2) acc.UpdateReader(ctx, in2)
assert.Equal(t, in2, acc.GetReader()) assert.Equal(t, in2, acc.GetReader())
@ -95,7 +94,7 @@ func TestAccountGetUpdateReader(t *testing.T) {
func TestAccountRead(t *testing.T) { func TestAccountRead(t *testing.T) {
ctx := context.Background() ctx := context.Background()
in := ioutil.NopCloser(bytes.NewBuffer([]byte{1, 2, 3})) in := io.NopCloser(bytes.NewBuffer([]byte{1, 2, 3}))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(ctx, stats, in, 1, "test") acc := newAccountSizeName(ctx, stats, in, 1, "test")
@ -137,7 +136,7 @@ func testAccountWriteTo(t *testing.T, withBuffer bool) {
for i := range buf { for i := range buf {
buf[i] = byte(i % 251) buf[i] = byte(i % 251)
} }
in := ioutil.NopCloser(bytes.NewBuffer(buf)) in := io.NopCloser(bytes.NewBuffer(buf))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(ctx, stats, in, int64(len(buf)), "test") acc := newAccountSizeName(ctx, stats, in, int64(len(buf)), "test")
if withBuffer { if withBuffer {
@ -178,7 +177,7 @@ func TestAccountWriteToWithBuffer(t *testing.T) {
func TestAccountString(t *testing.T) { func TestAccountString(t *testing.T) {
ctx := context.Background() ctx := context.Background()
in := ioutil.NopCloser(bytes.NewBuffer([]byte{1, 2, 3})) in := io.NopCloser(bytes.NewBuffer([]byte{1, 2, 3}))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(ctx, stats, in, 3, "test") acc := newAccountSizeName(ctx, stats, in, 3, "test")
@ -199,13 +198,13 @@ func TestAccountString(t *testing.T) {
// Test the Accounter interface methods on Account and accountStream // Test the Accounter interface methods on Account and accountStream
func TestAccountAccounter(t *testing.T) { func TestAccountAccounter(t *testing.T) {
ctx := context.Background() ctx := context.Background()
in := ioutil.NopCloser(bytes.NewBuffer([]byte{1, 2, 3})) in := io.NopCloser(bytes.NewBuffer([]byte{1, 2, 3}))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(ctx, stats, in, 3, "test") acc := newAccountSizeName(ctx, stats, in, 3, "test")
assert.True(t, in == acc.OldStream()) assert.True(t, in == acc.OldStream())
in2 := ioutil.NopCloser(bytes.NewBuffer([]byte{2, 3, 4})) in2 := io.NopCloser(bytes.NewBuffer([]byte{2, 3, 4}))
acc.SetStream(in2) acc.SetStream(in2)
assert.True(t, in2 == acc.OldStream()) assert.True(t, in2 == acc.OldStream())
@ -228,7 +227,7 @@ func TestAccountAccounter(t *testing.T) {
assert.Equal(t, []byte{1, 2}, buf[:n]) assert.Equal(t, []byte{1, 2}, buf[:n])
// Test that we can get another accountstream out // Test that we can get another accountstream out
in3 := ioutil.NopCloser(bytes.NewBuffer([]byte{3, 1, 2})) in3 := io.NopCloser(bytes.NewBuffer([]byte{3, 1, 2}))
r2 := as.WrapStream(in3) r2 := as.WrapStream(in3)
as2, ok := r2.(Accounter) as2, ok := r2.(Accounter)
require.True(t, ok) require.True(t, ok)
@ -268,7 +267,7 @@ func TestAccountMaxTransfer(t *testing.T) {
ci.CutoffMode = oldMode ci.CutoffMode = oldMode
}() }()
in := ioutil.NopCloser(bytes.NewBuffer(make([]byte, 100))) in := io.NopCloser(bytes.NewBuffer(make([]byte, 100)))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(ctx, stats, in, 1, "test") acc := newAccountSizeName(ctx, stats, in, 1, "test")
@ -312,7 +311,7 @@ func TestAccountMaxTransferWriteTo(t *testing.T) {
ci.CutoffMode = oldMode ci.CutoffMode = oldMode
}() }()
in := ioutil.NopCloser(readers.NewPatternReader(1024)) in := io.NopCloser(readers.NewPatternReader(1024))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(ctx, stats, in, 1, "test") acc := newAccountSizeName(ctx, stats, in, 1, "test")
@ -326,7 +325,7 @@ func TestAccountMaxTransferWriteTo(t *testing.T) {
func TestAccountReadCtx(t *testing.T) { func TestAccountReadCtx(t *testing.T) {
ctx := context.Background() ctx := context.Background()
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
in := ioutil.NopCloser(bytes.NewBuffer(make([]byte, 100))) in := io.NopCloser(bytes.NewBuffer(make([]byte, 100)))
stats := NewStats(ctx) stats := NewStats(ctx)
acc := newAccountSizeName(ctx, stats, in, 1, "test") acc := newAccountSizeName(ctx, stats, in, 1, "test")

View File

@ -6,7 +6,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math/rand" "math/rand"
"strings" "strings"
"sync" "sync"
@ -23,7 +22,7 @@ import (
func TestAsyncReader(t *testing.T) { func TestAsyncReader(t *testing.T) {
ctx := context.Background() ctx := context.Background()
buf := ioutil.NopCloser(bytes.NewBufferString("Testbuffer")) buf := io.NopCloser(bytes.NewBufferString("Testbuffer"))
ar, err := New(ctx, buf, 4) ar, err := New(ctx, buf, 4)
require.NoError(t, err) require.NoError(t, err)
@ -48,7 +47,7 @@ func TestAsyncReader(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// Test Close without reading everything // Test Close without reading everything
buf = ioutil.NopCloser(bytes.NewBuffer(make([]byte, 50000))) buf = io.NopCloser(bytes.NewBuffer(make([]byte, 50000)))
ar, err = New(ctx, buf, 4) ar, err = New(ctx, buf, 4)
require.NoError(t, err) require.NoError(t, err)
err = ar.Close() err = ar.Close()
@ -59,7 +58,7 @@ func TestAsyncReader(t *testing.T) {
func TestAsyncWriteTo(t *testing.T) { func TestAsyncWriteTo(t *testing.T) {
ctx := context.Background() ctx := context.Background()
buf := ioutil.NopCloser(bytes.NewBufferString("Testbuffer")) buf := io.NopCloser(bytes.NewBufferString("Testbuffer"))
ar, err := New(ctx, buf, 4) ar, err := New(ctx, buf, 4)
require.NoError(t, err) require.NoError(t, err)
@ -85,7 +84,7 @@ func TestAsyncReaderErrors(t *testing.T) {
require.Error(t, err) require.Error(t, err)
// invalid buffer number // invalid buffer number
buf := ioutil.NopCloser(bytes.NewBufferString("Testbuffer")) buf := io.NopCloser(bytes.NewBufferString("Testbuffer"))
_, err = New(ctx, buf, 0) _, err = New(ctx, buf, 0)
require.Error(t, err) require.Error(t, err)
_, err = New(ctx, buf, -1) _, err = New(ctx, buf, -1)
@ -170,7 +169,7 @@ func TestAsyncReaderSizes(t *testing.T) {
bufsize := bufsizes[k] bufsize := bufsizes[k]
read := readmaker.fn(strings.NewReader(text)) read := readmaker.fn(strings.NewReader(text))
buf := bufio.NewReaderSize(read, bufsize) buf := bufio.NewReaderSize(read, bufsize)
ar, _ := New(ctx, ioutil.NopCloser(buf), l) ar, _ := New(ctx, io.NopCloser(buf), l)
s := bufreader.fn(ar) s := bufreader.fn(ar)
// "timeout" expects the Reader to recover, AsyncReader does not. // "timeout" expects the Reader to recover, AsyncReader does not.
if s != text && readmaker.name != "timeout" { if s != text && readmaker.name != "timeout" {
@ -211,7 +210,7 @@ func TestAsyncReaderWriteTo(t *testing.T) {
bufsize := bufsizes[k] bufsize := bufsizes[k]
read := readmaker.fn(strings.NewReader(text)) read := readmaker.fn(strings.NewReader(text))
buf := bufio.NewReaderSize(read, bufsize) buf := bufio.NewReaderSize(read, bufsize)
ar, _ := New(ctx, ioutil.NopCloser(buf), l) ar, _ := New(ctx, io.NopCloser(buf), l)
dst := &bytes.Buffer{} dst := &bytes.Buffer{}
_, err := ar.WriteTo(dst) _, err := ar.WriteTo(dst)
if err != nil && err != io.EOF && err != iotest.ErrTimeout { if err != nil && err != io.EOF && err != iotest.ErrTimeout {
@ -272,7 +271,7 @@ func testAsyncReaderClose(t *testing.T, writeto bool) {
close(started) close(started)
if writeto { if writeto {
// exercise the WriteTo path // exercise the WriteTo path
copyN, copyErr = a.WriteTo(ioutil.Discard) copyN, copyErr = a.WriteTo(io.Discard)
} else { } else {
// exercise the Read path // exercise the Read path
buf := make([]byte, 64*1024) buf := make([]byte, 64*1024)
@ -327,7 +326,7 @@ func TestAsyncReaderSkipBytes(t *testing.T) {
t.Run(fmt.Sprintf("%d", initialRead), func(t *testing.T) { t.Run(fmt.Sprintf("%d", initialRead), func(t *testing.T) {
for _, skip := range skips { for _, skip := range skips {
t.Run(fmt.Sprintf("%d", skip), func(t *testing.T) { t.Run(fmt.Sprintf("%d", skip), func(t *testing.T) {
ar, err := New(ctx, ioutil.NopCloser(bytes.NewReader(data)), buffers) ar, err := New(ctx, io.NopCloser(bytes.NewReader(data)), buffers)
require.NoError(t, err) require.NoError(t, err)
wantSkipFalse := false wantSkipFalse := false

View File

@ -4,7 +4,6 @@ package configfile
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -113,7 +112,7 @@ func (s *Storage) Save() error {
if err != nil { if err != nil {
return fmt.Errorf("failed to create config directory: %w", err) return fmt.Errorf("failed to create config directory: %w", err)
} }
f, err := ioutil.TempFile(dir, name) f, err := os.CreateTemp(dir, name)
if err != nil { if err != nil {
return fmt.Errorf("failed to create temp file for new config: %w", err) return fmt.Errorf("failed to create temp file for new config: %w", err)
} }

View File

@ -2,7 +2,6 @@ package configfile
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"runtime" "runtime"
"strings" "strings"
@ -30,7 +29,7 @@ fruit = banana
// Fill up a temporary config file with the testdata filename passed in // Fill up a temporary config file with the testdata filename passed in
func setConfigFile(t *testing.T, data string) func() { func setConfigFile(t *testing.T, data string) func() {
out, err := ioutil.TempFile("", "rclone-configfile-test") out, err := os.CreateTemp("", "rclone-configfile-test")
require.NoError(t, err) require.NoError(t, err)
filePath := out.Name() filePath := out.Name()
@ -160,7 +159,7 @@ type = number3
`, toUnix(buf)) `, toUnix(buf))
t.Run("Save", func(t *testing.T) { t.Run("Save", func(t *testing.T) {
require.NoError(t, data.Save()) require.NoError(t, data.Save())
buf, err := ioutil.ReadFile(config.GetConfigPath()) buf, err := os.ReadFile(config.GetConfigPath())
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, `[one] assert.Equal(t, `[one]
fruit = potato fruit = potato

View File

@ -10,7 +10,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
@ -128,7 +127,7 @@ func Decrypt(b io.ReadSeeker) (io.Reader, error) {
// Encrypted content is base64 encoded. // Encrypted content is base64 encoded.
dec := base64.NewDecoder(base64.StdEncoding, r) dec := base64.NewDecoder(base64.StdEncoding, r)
box, err := ioutil.ReadAll(dec) box, err := io.ReadAll(dec)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to load base64 encoded data: %w", err) return nil, fmt.Errorf("failed to load base64 encoded data: %w", err)
} }
@ -140,7 +139,7 @@ func Decrypt(b io.ReadSeeker) (io.Reader, error) {
for { for {
if envKeyFile := os.Getenv("_RCLONE_CONFIG_KEY_FILE"); len(envKeyFile) > 0 { if envKeyFile := os.Getenv("_RCLONE_CONFIG_KEY_FILE"); len(envKeyFile) > 0 {
fs.Debugf(nil, "attempting to obtain configKey from temp file %s", envKeyFile) fs.Debugf(nil, "attempting to obtain configKey from temp file %s", envKeyFile)
obscuredKey, err := ioutil.ReadFile(envKeyFile) obscuredKey, err := os.ReadFile(envKeyFile)
if err != nil { if err != nil {
errRemove := os.Remove(envKeyFile) errRemove := os.Remove(envKeyFile)
if errRemove != nil { if errRemove != nil {
@ -212,7 +211,7 @@ func Encrypt(src io.Reader, dst io.Writer) error {
var key [32]byte var key [32]byte
copy(key[:], configKey[:32]) copy(key[:], configKey[:32])
data, err := ioutil.ReadAll(src) data, err := io.ReadAll(src)
if err != nil { if err != nil {
return err return err
} }
@ -256,7 +255,7 @@ func SetConfigPassword(password string) error {
} }
configKey = sha.Sum(nil) configKey = sha.Sum(nil)
if PassConfigKeyForDaemonization { if PassConfigKeyForDaemonization {
tempFile, err := ioutil.TempFile("", "rclone") tempFile, err := os.CreateTemp("", "rclone")
if err != nil { if err != nil {
return fmt.Errorf("cannot create temp file to store configKey: %w", err) return fmt.Errorf("cannot create temp file to store configKey: %w", err)
} }

View File

@ -7,7 +7,6 @@ package config_test
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"testing" "testing"
@ -37,7 +36,7 @@ func testConfigFile(t *testing.T, options []fs.Option, configFileName string) fu
_ = os.Unsetenv("_RCLONE_CONFIG_KEY_FILE") _ = os.Unsetenv("_RCLONE_CONFIG_KEY_FILE")
_ = os.Unsetenv("RCLONE_CONFIG_PASS") _ = os.Unsetenv("RCLONE_CONFIG_PASS")
// create temp config file // create temp config file
tempFile, err := ioutil.TempFile("", configFileName) tempFile, err := os.CreateTemp("", configFileName)
assert.NoError(t, err) assert.NoError(t, err)
path := tempFile.Name() path := tempFile.Name()
assert.NoError(t, tempFile.Close()) assert.NoError(t, tempFile.Close())

View File

@ -3,7 +3,6 @@ package filter
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"strings" "strings"
"sync" "sync"
@ -30,7 +29,7 @@ func TestNewFilterDefault(t *testing.T) {
// testFile creates a temp file with the contents // testFile creates a temp file with the contents
func testFile(t *testing.T, contents string) string { func testFile(t *testing.T, contents string) string {
out, err := ioutil.TempFile("", "filter_test") out, err := os.CreateTemp("", "filter_test")
require.NoError(t, err) require.NoError(t, err)
defer func() { defer func() {
err := out.Close() err := out.Close()

View File

@ -6,12 +6,12 @@ import (
"context" "context"
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"io/ioutil"
"log" "log"
"net" "net"
"net/http" "net/http"
"net/http/cookiejar" "net/http/cookiejar"
"net/http/httputil" "net/http/httputil"
"os"
"sync" "sync"
"time" "time"
@ -74,7 +74,7 @@ func NewTransportCustom(ctx context.Context, customize func(*http.Transport)) ht
// Load CA cert // Load CA cert
if ci.CaCert != "" { if ci.CaCert != "" {
caCert, err := ioutil.ReadFile(ci.CaCert) caCert, err := os.ReadFile(ci.CaCert)
if err != nil { if err != nil {
log.Fatalf("Failed to read --ca-cert: %v", err) log.Fatalf("Failed to read --ca-cert: %v", err)
} }

View File

@ -3,7 +3,6 @@ package fspath
import ( import (
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -424,7 +423,7 @@ func TestParse(t *testing.T) {
if *makeCorpus { if *makeCorpus {
// write the test corpus for fuzzing // write the test corpus for fuzzing
require.NoError(t, os.MkdirAll("corpus", 0777)) require.NoError(t, os.MkdirAll("corpus", 0777))
require.NoError(t, ioutil.WriteFile(fmt.Sprintf("corpus/%02d", testNumber), []byte(test.in), 0666)) require.NoError(t, os.WriteFile(fmt.Sprintf("corpus/%02d", testNumber), []byte(test.in), 0666))
} }
} }

View File

@ -6,7 +6,6 @@ import (
"context" "context"
"crypto/md5" "crypto/md5"
"encoding/base64" "encoding/base64"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -117,7 +116,7 @@ func ConfigString(f Fs) string {
// //
// No cleanup is performed, the caller must call Purge on the Fs themselves. // No cleanup is performed, the caller must call Purge on the Fs themselves.
func TemporaryLocalFs(ctx context.Context) (Fs, error) { func TemporaryLocalFs(ctx context.Context) (Fs, error) {
path, err := ioutil.TempDir("", "rclone-spool") path, err := os.MkdirTemp("", "rclone-spool")
if err == nil { if err == nil {
err = os.Remove(path) err = os.Remove(path)
} }

View File

@ -6,7 +6,6 @@ import (
"context" "context"
"errors" "errors"
"io" "io"
"io/ioutil"
"time" "time"
"github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs"
@ -214,7 +213,7 @@ func (o *MemoryObject) Open(ctx context.Context, options ...fs.OpenOption) (io.R
} }
} }
} }
return ioutil.NopCloser(bytes.NewBuffer(content)), nil return io.NopCloser(bytes.NewBuffer(content)), nil
} }
// Update in to the object with the modTime given of the given size // Update in to the object with the modTime given of the given size
@ -225,7 +224,7 @@ func (o *MemoryObject) Update(ctx context.Context, in io.Reader, src fs.ObjectIn
if size == 0 { if size == 0 {
o.content = nil o.content = nil
} else if size < 0 || int64(cap(o.content)) < size { } else if size < 0 || int64(cap(o.content)) < size {
o.content, err = ioutil.ReadAll(in) o.content, err = io.ReadAll(in)
} else { } else {
o.content = o.content[:size] o.content = o.content[:size]
_, err = io.ReadFull(in, o.content) _, err = io.ReadFull(in, o.content)

View File

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"context" "context"
"io" "io"
"io/ioutil"
"testing" "testing"
"time" "time"
@ -110,7 +109,7 @@ func TestMemoryObject(t *testing.T) {
assert.Equal(t, newNow, o.ModTime(context.Background())) assert.Equal(t, newNow, o.ModTime(context.Background()))
checkOpen := func(rc io.ReadCloser, expected string) { checkOpen := func(rc io.ReadCloser, expected string) {
actual, err := ioutil.ReadAll(rc) actual, err := io.ReadAll(rc)
assert.NoError(t, err) assert.NoError(t, err)
err = rc.Close() err = rc.Close()
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -11,7 +11,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"mime" "mime"
"net/http" "net/http"
"os" "os"
@ -1430,7 +1429,7 @@ func Rcat(ctx context.Context, fdst fs.Fs, dstFileName string, in io.ReadCloser,
if SkipDestructive(ctx, dstFileName, "upload from pipe") { if SkipDestructive(ctx, dstFileName, "upload from pipe") {
// prevents "broken pipe" errors // prevents "broken pipe" errors
_, err = io.Copy(ioutil.Discard, in) _, err = io.Copy(io.Discard, in)
return nil, err return nil, err
} }
@ -1735,12 +1734,12 @@ func RcatSize(ctx context.Context, fdst fs.Fs, dstFileName string, in io.ReadClo
defer func() { defer func() {
tr.Done(ctx, err) tr.Done(ctx, err)
}() }()
body := ioutil.NopCloser(in) // we let the server close the body body := io.NopCloser(in) // we let the server close the body
in := tr.Account(ctx, body) // account the transfer (no buffering) in := tr.Account(ctx, body) // account the transfer (no buffering)
if SkipDestructive(ctx, dstFileName, "upload from pipe") { if SkipDestructive(ctx, dstFileName, "upload from pipe") {
// prevents "broken pipe" errors // prevents "broken pipe" errors
_, err = io.Copy(ioutil.Discard, in) _, err = io.Copy(io.Discard, in)
return nil, err return nil, err
} }

View File

@ -26,7 +26,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
@ -320,7 +319,7 @@ func TestHashSumsWithErrors(t *testing.T) {
func TestHashStream(t *testing.T) { func TestHashStream(t *testing.T) {
reader := strings.NewReader("") reader := strings.NewReader("")
in := ioutil.NopCloser(reader) in := io.NopCloser(reader)
out := &bytes.Buffer{} out := &bytes.Buffer{}
for _, test := range []struct { for _, test := range []struct {
input string input string
@ -1590,11 +1589,11 @@ func TestRcat(t *testing.T) {
data2 := string(make([]byte, ci.StreamingUploadCutoff+1)) data2 := string(make([]byte, ci.StreamingUploadCutoff+1))
path2 := prefix + "big_file_from_pipe" path2 := prefix + "big_file_from_pipe"
in := ioutil.NopCloser(strings.NewReader(data1)) in := io.NopCloser(strings.NewReader(data1))
_, err := operations.Rcat(ctx, r.Fremote, path1, in, t1) _, err := operations.Rcat(ctx, r.Fremote, path1, in, t1)
require.NoError(t, err) require.NoError(t, err)
in = ioutil.NopCloser(strings.NewReader(data2)) in = io.NopCloser(strings.NewReader(data2))
_, err = operations.Rcat(ctx, r.Fremote, path2, in, t2) _, err = operations.Rcat(ctx, r.Fremote, path2, in, t2)
require.NoError(t, err) require.NoError(t, err)
@ -1621,15 +1620,15 @@ func TestRcatSize(t *testing.T) {
file1 := r.WriteFile("potato1", body, t1) file1 := r.WriteFile("potato1", body, t1)
file2 := r.WriteFile("potato2", body, t2) file2 := r.WriteFile("potato2", body, t2)
// Test with known length // Test with known length
bodyReader := ioutil.NopCloser(strings.NewReader(body)) bodyReader := io.NopCloser(strings.NewReader(body))
obj, err := operations.RcatSize(ctx, r.Fremote, file1.Path, bodyReader, int64(len(body)), file1.ModTime) obj, err := operations.RcatSize(ctx, r.Fremote, file1.Path, bodyReader, int64(len(body)), file1.ModTime)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, int64(len(body)), obj.Size()) assert.Equal(t, int64(len(body)), obj.Size())
assert.Equal(t, file1.Path, obj.Remote()) assert.Equal(t, file1.Path, obj.Remote())
// Test with unknown length // Test with unknown length
bodyReader = ioutil.NopCloser(strings.NewReader(body)) // reset Reader bodyReader = io.NopCloser(strings.NewReader(body)) // reset Reader
ioutil.NopCloser(strings.NewReader(body)) io.NopCloser(strings.NewReader(body))
obj, err = operations.RcatSize(ctx, r.Fremote, file2.Path, bodyReader, -1, file2.ModTime) obj, err = operations.RcatSize(ctx, r.Fremote, file2.Path, bodyReader, -1, file2.ModTime)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, int64(len(body)), obj.Size()) assert.Equal(t, int64(len(body)), obj.Size())

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"errors" "errors"
"io" "io"
"io/ioutil"
"testing" "testing"
"github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs"
@ -83,7 +82,7 @@ func TestReOpen(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
// Check contents read correctly // Check contents read correctly
got, err := ioutil.ReadAll(h) got, err := io.ReadAll(h)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, expectedRead, got) assert.Equal(t, expectedRead, got)
@ -118,7 +117,7 @@ func TestReOpen(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
// check contents // check contents
got, err := ioutil.ReadAll(h) got, err := io.ReadAll(h)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, expectedRead, got) assert.Equal(t, expectedRead, got)
@ -132,7 +131,7 @@ func TestReOpen(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
// check contents // check contents
got, err := ioutil.ReadAll(h) got, err := io.ReadAll(h)
assert.Equal(t, errorTestError, err) assert.Equal(t, errorTestError, err)
assert.Equal(t, expectedRead[:6], got) assert.Equal(t, expectedRead[:6], got)

View File

@ -5,7 +5,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
@ -77,7 +76,7 @@ func TestRcServer(t *testing.T) {
} }
require.NoError(t, err) require.NoError(t, err)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
_ = resp.Body.Close() _ = resp.Body.Close()
require.NoError(t, err) require.NoError(t, err)
@ -132,7 +131,7 @@ func testServer(t *testing.T, tests []testRun, opt *rc.Options) {
resp := w.Result() resp := w.Result()
assert.Equal(t, test.Status, resp.StatusCode) assert.Equal(t, test.Status, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
require.NoError(t, err) require.NoError(t, err)
if test.Contains == nil { if test.Contains == nil {

View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"net/http" "net/http"
"net/http/httputil" "net/http/httputil"
"net/url" "net/url"
@ -112,7 +111,7 @@ func (p *Plugins) readFromFile() (err error) {
availablePluginsJSON := filepath.Join(pluginsConfigPath, p.fileName) availablePluginsJSON := filepath.Join(pluginsConfigPath, p.fileName)
_, err = os.Stat(availablePluginsJSON) _, err = os.Stat(availablePluginsJSON)
if err == nil { if err == nil {
data, err := ioutil.ReadFile(availablePluginsJSON) data, err := os.ReadFile(availablePluginsJSON)
if err != nil { if err != nil {
return err return err
} }
@ -134,7 +133,7 @@ func (p *Plugins) readFromFile() (err error) {
func (p *Plugins) addPlugin(pluginName string, packageJSONPath string) (err error) { func (p *Plugins) addPlugin(pluginName string, packageJSONPath string) (err error) {
p.mutex.Lock() p.mutex.Lock()
defer p.mutex.Unlock() defer p.mutex.Unlock()
data, err := ioutil.ReadFile(packageJSONPath) data, err := os.ReadFile(packageJSONPath)
if err != nil { if err != nil {
return err return err
} }
@ -187,7 +186,7 @@ func (p *Plugins) writeToFile() (err error) {
if err != nil { if err != nil {
fs.Logf(nil, "%s", err) fs.Logf(nil, "%s", err)
} }
err = ioutil.WriteFile(availablePluginsJSON, file, 0755) err = os.WriteFile(availablePluginsJSON, file, 0755)
if err != nil { if err != nil {
fs.Logf(nil, "%s", err) fs.Logf(nil, "%s", err)
} }

View File

@ -7,7 +7,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -64,7 +63,7 @@ func CheckAndDownloadWebGUIRelease(checkUpdate bool, forceUpdate bool, fetchURL
if err != nil { if err != nil {
return fmt.Errorf("error checking for web gui release update, skipping update: %w", err) return fmt.Errorf("error checking for web gui release update, skipping update: %w", err)
} }
dat, err := ioutil.ReadFile(tagPath) dat, err := os.ReadFile(tagPath)
tagsMatch := false tagsMatch := false
if err != nil { if err != nil {
fs.Errorf(nil, "Error reading tag file at %s ", tagPath) fs.Errorf(nil, "Error reading tag file at %s ", tagPath)
@ -129,7 +128,7 @@ func CheckAndDownloadWebGUIRelease(checkUpdate bool, forceUpdate bool, fetchURL
fs.Logf(nil, "Downloaded ZIP cannot be deleted") fs.Logf(nil, "Downloaded ZIP cannot be deleted")
} }
err = ioutil.WriteFile(tagPath, []byte(tag), 0644) err = os.WriteFile(tagPath, []byte(tag), 0644)
if err != nil { if err != nil {
fs.Infof(nil, "Cannot write tag file. You may be required to redownload the binary next time.") fs.Infof(nil, "Cannot write tag file. You may be required to redownload the binary next time.")
} }

View File

@ -9,7 +9,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"math/rand" "math/rand"
"os" "os"
@ -411,7 +410,7 @@ func Time(timeString string) time.Time {
// LocalRemote creates a temporary directory name for local remotes // LocalRemote creates a temporary directory name for local remotes
func LocalRemote() (path string, err error) { func LocalRemote() (path string, err error) {
path, err = ioutil.TempDir("", "rclone") path, err = os.MkdirTemp("", "rclone")
if err == nil { if err == nil {
// Now remove the directory // Now remove the directory
err = os.Remove(path) err = os.Remove(path)

View File

@ -12,7 +12,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math/bits" "math/bits"
"os" "os"
"path" "path"
@ -303,7 +302,7 @@ func ReadObject(ctx context.Context, t *testing.T, obj fs.Object, limit int64, o
if limit >= 0 { if limit >= 0 {
r = &io.LimitedReader{R: r, N: limit} r = &io.LimitedReader{R: r, N: limit}
} }
contents, err := ioutil.ReadAll(r) contents, err := io.ReadAll(r)
require.NoError(t, err, what) require.NoError(t, err, what)
err = in.Close() err = in.Close()
require.NoError(t, err, what) require.NoError(t, err, what)

View File

@ -29,7 +29,6 @@ import (
"context" "context"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os" "os"
"path" "path"
@ -99,7 +98,7 @@ func newRun() *Run {
r.Fatalf("Failed to open remote %q: %v", *RemoteName, err) r.Fatalf("Failed to open remote %q: %v", *RemoteName, err)
} }
r.LocalName, err = ioutil.TempDir("", "rclone") r.LocalName, err = os.MkdirTemp("", "rclone")
if err != nil { if err != nil {
r.Fatalf("Failed to create temp dir: %v", err) r.Fatalf("Failed to create temp dir: %v", err)
} }
@ -221,7 +220,7 @@ func (r *Run) WriteFile(filePath, content string, t time.Time) Item {
if err != nil { if err != nil {
r.Fatalf("Failed to make directories %q: %v", dirPath, err) r.Fatalf("Failed to make directories %q: %v", dirPath, err)
} }
err = ioutil.WriteFile(filePath, []byte(content), 0600) err = os.WriteFile(filePath, []byte(content), 0600)
if err != nil { if err != nil {
r.Fatalf("Failed to write file %q: %v", filePath, err) r.Fatalf("Failed to write file %q: %v", filePath, err)
} }

View File

@ -4,8 +4,8 @@ package main
import ( import (
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os"
"path" "path"
"github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs"
@ -110,7 +110,7 @@ type Config struct {
// NewConfig reads the config file // NewConfig reads the config file
func NewConfig(configFile string) (*Config, error) { func NewConfig(configFile string) (*Config, error) {
d, err := ioutil.ReadFile(configFile) d, err := os.ReadFile(configFile)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read config file: %w", err) return nil, fmt.Errorf("failed to read config file: %w", err)
} }

View File

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"html/template" "html/template"
"io/ioutil"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@ -69,7 +68,7 @@ func NewReport() *Report {
r.DateTime = r.StartTime.Format(timeFormat) r.DateTime = r.StartTime.Format(timeFormat)
// Find previous log directory if possible // Find previous log directory if possible
names, err := ioutil.ReadDir(*outputDir) names, err := os.ReadDir(*outputDir)
if err == nil && len(names) > 0 { if err == nil && len(names) > 0 {
r.Previous = names[len(names)-1].Name() r.Previous = names[len(names)-1].Name()
} }
@ -152,7 +151,7 @@ func (r *Report) LogJSON() {
if err != nil { if err != nil {
log.Fatalf("Failed to marshal data for index.json: %v", err) log.Fatalf("Failed to marshal data for index.json: %v", err)
} }
err = ioutil.WriteFile(path.Join(r.LogDir, "index.json"), out, 0666) err = os.WriteFile(path.Join(r.LogDir, "index.json"), out, 0666)
if err != nil { if err != nil {
log.Fatalf("Failed to write index.json: %v", err) log.Fatalf("Failed to write index.json: %v", err)
} }

View File

@ -9,8 +9,8 @@ import (
"encoding/base64" "encoding/base64"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"math" "math"
"os"
"strings" "strings"
"unicode/utf8" "unicode/utf8"
@ -43,7 +43,7 @@ func main() {
for i := range histogram[:] { for i := range histogram[:] {
histogram[i] = 0 histogram[i] = 0
} }
b, err := ioutil.ReadFile(*indexFile) b, err := os.ReadFile(*indexFile)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -3,7 +3,6 @@ package file
import ( import (
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"path" "path"
"runtime" "runtime"
@ -16,7 +15,7 @@ import (
// This lists dir and checks the listing is as expected without checking the size // This lists dir and checks the listing is as expected without checking the size
func checkListingNoSize(t *testing.T, dir string, want []string) { func checkListingNoSize(t *testing.T, dir string, want []string) {
var got []string var got []string
nodes, err := ioutil.ReadDir(dir) nodes, err := os.ReadDir(dir)
require.NoError(t, err) require.NoError(t, err)
for _, node := range nodes { for _, node := range nodes {
got = append(got, fmt.Sprintf("%s,%v", node.Name(), node.IsDir())) got = append(got, fmt.Sprintf("%s,%v", node.Name(), node.IsDir()))
@ -27,10 +26,12 @@ func checkListingNoSize(t *testing.T, dir string, want []string) {
// This lists dir and checks the listing is as expected // This lists dir and checks the listing is as expected
func checkListing(t *testing.T, dir string, want []string) { func checkListing(t *testing.T, dir string, want []string) {
var got []string var got []string
nodes, err := ioutil.ReadDir(dir) nodes, err := os.ReadDir(dir)
require.NoError(t, err) require.NoError(t, err)
for _, node := range nodes { for _, node := range nodes {
got = append(got, fmt.Sprintf("%s,%d,%v", node.Name(), node.Size(), node.IsDir())) info, err := node.Info()
assert.NoError(t, err)
got = append(got, fmt.Sprintf("%s,%d,%v", node.Name(), info.Size(), node.IsDir()))
} }
assert.Equal(t, want, got) assert.Equal(t, want, got)
} }

View File

@ -7,10 +7,10 @@ import (
"crypto/x509" "crypto/x509"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"net" "net"
"net/http" "net/http"
"os"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -187,7 +187,7 @@ func NewServer(listeners, tlsListeners []net.Listener, opt Options) (Server, err
return nil, err return nil, err
} }
certpool := x509.NewCertPool() certpool := x509.NewCertPool()
pem, err := ioutil.ReadFile(opt.ClientCA) pem, err := os.ReadFile(opt.ClientCA)
if err != nil { if err != nil {
log.Fatalf("Failed to read client certificate authority: %v", err) log.Fatalf("Failed to read client certificate authority: %v", err)
return nil, err return nil, err

View File

@ -3,7 +3,7 @@ package serve
import ( import (
"errors" "errors"
"html/template" "html/template"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
@ -94,7 +94,7 @@ func TestError(t *testing.T) {
Error("potato", w, "sausage", err) Error("potato", w, "sausage", err)
resp := w.Result() resp := w.Result()
assert.Equal(t, http.StatusInternalServerError, resp.StatusCode) assert.Equal(t, http.StatusInternalServerError, resp.StatusCode)
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "sausage.\n", string(body)) assert.Equal(t, "sausage.\n", string(body))
} }
@ -108,7 +108,7 @@ func TestServe(t *testing.T) {
d.Serve(w, r) d.Serve(w, r)
resp := w.Result() resp := w.Result()
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
assert.Equal(t, `<!DOCTYPE html> assert.Equal(t, `<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>

View File

@ -1,7 +1,7 @@
package serve package serve
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -17,7 +17,7 @@ func TestObjectBadMethod(t *testing.T) {
Object(w, r, o) Object(w, r, o)
resp := w.Result() resp := w.Result()
assert.Equal(t, http.StatusMethodNotAllowed, resp.StatusCode) assert.Equal(t, http.StatusMethodNotAllowed, resp.StatusCode)
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "Method Not Allowed\n", string(body)) assert.Equal(t, "Method Not Allowed\n", string(body))
} }
@ -30,7 +30,7 @@ func TestObjectHEAD(t *testing.T) {
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
assert.Equal(t, "5", resp.Header.Get("Content-Length")) assert.Equal(t, "5", resp.Header.Get("Content-Length"))
assert.Equal(t, "bytes", resp.Header.Get("Accept-Ranges")) assert.Equal(t, "bytes", resp.Header.Get("Accept-Ranges"))
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "", string(body)) assert.Equal(t, "", string(body))
} }
@ -43,7 +43,7 @@ func TestObjectGET(t *testing.T) {
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
assert.Equal(t, "5", resp.Header.Get("Content-Length")) assert.Equal(t, "5", resp.Header.Get("Content-Length"))
assert.Equal(t, "bytes", resp.Header.Get("Accept-Ranges")) assert.Equal(t, "bytes", resp.Header.Get("Accept-Ranges"))
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "hello", string(body)) assert.Equal(t, "hello", string(body))
} }
@ -58,7 +58,7 @@ func TestObjectRange(t *testing.T) {
assert.Equal(t, "3", resp.Header.Get("Content-Length")) assert.Equal(t, "3", resp.Header.Get("Content-Length"))
assert.Equal(t, "bytes", resp.Header.Get("Accept-Ranges")) assert.Equal(t, "bytes", resp.Header.Get("Accept-Ranges"))
assert.Equal(t, "bytes 3-5/10", resp.Header.Get("Content-Range")) assert.Equal(t, "bytes 3-5/10", resp.Header.Get("Content-Range"))
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "345", string(body)) assert.Equal(t, "345", string(body))
} }
@ -71,6 +71,6 @@ func TestObjectBadRange(t *testing.T) {
resp := w.Result() resp := w.Result()
assert.Equal(t, http.StatusBadRequest, resp.StatusCode) assert.Equal(t, http.StatusBadRequest, resp.StatusCode)
assert.Equal(t, "10", resp.Header.Get("Content-Length")) assert.Equal(t, "10", resp.Header.Get("Content-Length"))
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "Bad Request\n", string(body)) assert.Equal(t, "Bad Request\n", string(body))
} }

View File

@ -10,7 +10,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"strings" "strings"
"time" "time"
@ -96,7 +95,7 @@ func Config(id, name string, claims *jws.ClaimSet, header *jws.Header, queryPara
} }
func bodyToString(responseBody io.Reader) (bodyString string, err error) { func bodyToString(responseBody io.Reader) (bodyString string, err error) {
bodyBytes, err := ioutil.ReadAll(responseBody) bodyBytes, err := io.ReadAll(responseBody)
if err != nil { if err != nil {
return "", err return "", err
} }

View File

@ -6,7 +6,6 @@ package plugin
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"plugin" "plugin"
@ -19,7 +18,7 @@ func init() {
return return
} }
// Get file names of plugin dir // Get file names of plugin dir
listing, err := ioutil.ReadDir(dir) listing, err := os.ReadDir(dir)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, "Failed to open plugin directory:", err) fmt.Fprintln(os.Stderr, "Failed to open plugin directory:", err)
} }

View File

@ -2,7 +2,6 @@ package readers
import ( import (
"io" "io"
"io/ioutil"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -13,7 +12,7 @@ func TestPatternReader(t *testing.T) {
b2 := make([]byte, 1) b2 := make([]byte, 1)
r := NewPatternReader(0) r := NewPatternReader(0)
b, err := ioutil.ReadAll(r) b, err := io.ReadAll(r)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, []byte{}, b) assert.Equal(t, []byte{}, b)
n, err := r.Read(b2) n, err := r.Read(b2)
@ -21,7 +20,7 @@ func TestPatternReader(t *testing.T) {
require.Equal(t, 0, n) require.Equal(t, 0, n)
r = NewPatternReader(10) r = NewPatternReader(10)
b, err = ioutil.ReadAll(r) b, err = io.ReadAll(r)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, b) assert.Equal(t, []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, b)
n, err = r.Read(b2) n, err = r.Read(b2)
@ -31,7 +30,7 @@ func TestPatternReader(t *testing.T) {
func TestPatternReaderSeek(t *testing.T) { func TestPatternReaderSeek(t *testing.T) {
r := NewPatternReader(1024) r := NewPatternReader(1024)
b, err := ioutil.ReadAll(r) b, err := io.ReadAll(r)
require.NoError(t, err) require.NoError(t, err)
for i := range b { for i := range b {

View File

@ -11,7 +11,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"mime/multipart" "mime/multipart"
"net/http" "net/http"
"net/url" "net/url"
@ -44,7 +43,7 @@ func NewClient(c *http.Client) *Client {
// ReadBody reads resp.Body into result, closing the body // ReadBody reads resp.Body into result, closing the body
func ReadBody(resp *http.Response) (result []byte, err error) { func ReadBody(resp *http.Response) (result []byte, err error) {
defer fs.CheckClose(resp.Body, &err) defer fs.CheckClose(resp.Body, &err)
return ioutil.ReadAll(resp.Body) return io.ReadAll(resp.Body)
} }
// defaultErrorHandler doesn't attempt to parse the http body, just // defaultErrorHandler doesn't attempt to parse the http body, just

View File

@ -3,7 +3,7 @@ package vfs
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"testing" "testing"
@ -168,7 +168,7 @@ func fileCheckContents(t *testing.T, file *File) {
fd, err := file.Open(os.O_RDONLY) fd, err := file.Open(os.O_RDONLY)
require.NoError(t, err) require.NoError(t, err)
contents, err := ioutil.ReadAll(fd) contents, err := io.ReadAll(fd)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, "file1 contents", string(contents)) assert.Equal(t, "file1 contents", string(contents))
@ -217,7 +217,7 @@ func TestFileOpenReadUnknownSize(t *testing.T) {
assert.Equal(t, int64(0), fd.Size()) assert.Equal(t, int64(0), fd.Size())
// check the contents are not empty even though size is empty // check the contents are not empty even though size is empty
gotContents, err := ioutil.ReadAll(fd) gotContents, err := io.ReadAll(fd)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, contents, gotContents) assert.Equal(t, contents, gotContents)
t.Logf("gotContents = %q", gotContents) t.Logf("gotContents = %q", gotContents)

View File

@ -17,7 +17,6 @@ package main
import ( import (
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"os" "os"
"strings" "strings"
@ -196,7 +195,7 @@ type openTest struct{
// combination of flags. This obeys Unix semantics even on Windows. // combination of flags. This obeys Unix semantics even on Windows.
var openTests = []openTest{ var openTests = []openTest{
`) `)
f, err := ioutil.TempFile("", "open-test") f, err := os.CreateTemp("", "open-test")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

Some files were not shown because too many files have changed in this diff Show More