Skip to content

Commit

Permalink
Not use deprecated io/ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
tchssk committed Aug 29, 2023
1 parent 84435fe commit 0799cd2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions providers/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ package fs

import (
"errors"
"io"
"io/fs"
"io/ioutil"
)

// FS implements an fs.FS provider.
Expand All @@ -32,7 +32,7 @@ func (f *FS) ReadBytes() ([]byte, error) {
}
defer fd.Close()

return ioutil.ReadAll(fd)
return io.ReadAll(fd)
}

// Read is not supported by the fs.FS provider.
Expand Down
4 changes: 2 additions & 2 deletions providers/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package s3

import (
"errors"
"io/ioutil"
"io"

"github.com/rhnvrm/simples3"
)
Expand Down Expand Up @@ -56,7 +56,7 @@ func (r *S3) ReadBytes() ([]byte, error) {

defer resp.Close()

data, err := ioutil.ReadAll(resp)
data, err := io.ReadAll(resp)
if err != nil {
return nil, err
}
Expand Down
9 changes: 4 additions & 5 deletions tests/koanf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -438,9 +437,9 @@ func TestWatchFile(t *testing.T) {
)

// Create a tmp config file.
tmpDir, _ := ioutil.TempDir("", "koanf_*") // TODO: replace with t.TempDir() as of go v1.15
tmpDir, _ := os.MkdirTemp("", "koanf_*") // TODO: replace with t.TempDir() as of go v1.15
tmpFile := filepath.Join(tmpDir, "koanf_mock")
err := ioutil.WriteFile(tmpFile, []byte(`{"parent": {"name": "name1"}}`), 0600) // TODO: replace with os.WriteFile as of go v1.16
err := os.WriteFile(tmpFile, []byte(`{"parent": {"name": "name1"}}`), 0600)
require.NoError(t, err, "error creating temp config file: %v", err)

// Load the new config and watch it for changes.
Expand Down Expand Up @@ -469,7 +468,7 @@ func TestWatchFile(t *testing.T) {

// Wait a second and change the file.
time.Sleep(1 * time.Second)
ioutil.WriteFile(tmpFile, []byte(`{"parent": {"name": "name2"}}`), 0600) // TODO: replace with os.WriteFile as of go v1.16
os.WriteFile(tmpFile, []byte(`{"parent": {"name": "name2"}}`), 0600)
wg.Wait()

assert.Condition(func() bool {
Expand All @@ -482,7 +481,7 @@ func TestWatchFileSymlink(t *testing.T) {
assert = assert.New(t)
k = koanf.New(delim)
)
tmpDir, _ := ioutil.TempDir("", "koanf_*") // TODO: replace with t.TempDir() as of go v1.15
tmpDir, _ := os.MkdirTemp("", "koanf_*") // TODO: replace with t.TempDir() as of go v1.15

// Create a symlink.
symPath := filepath.Join(tmpDir, "koanf_test_symlink")
Expand Down

0 comments on commit 0799cd2

Please sign in to comment.