Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not use deprecated io/ioutil #226

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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