Skip to content

Commit

Permalink
Revert "Not use deprecated io/ioutil"
Browse files Browse the repository at this point in the history
This reverts commit 055a274.
  • Loading branch information
tchssk committed Aug 29, 2023
1 parent 055a274 commit 9fe747a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 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 io.ReadAll(fd)
return ioutil.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"
"io/ioutil"

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

defer resp.Close()

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

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

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

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

assert.Condition(func() bool {
Expand All @@ -481,7 +482,7 @@ func TestWatchFileSymlink(t *testing.T) {
assert = assert.New(t)
k = koanf.New(delim)
)
tmpDir := t.TempDir()
tmpDir, _ := ioutil.TempDir("", "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 9fe747a

Please sign in to comment.