mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
Replace uses of ioutil
ioutil package was deprecated in Go 1.16, replace all uses with their respective replacements. This patch was generated with a combination of `gofmt -r`, `eg`, and manually (for `ioutil.ReadDir`).
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
package safeio
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"syscall"
|
||||
@@ -14,7 +13,7 @@ type FileOp func(fname string) error
|
||||
|
||||
// WriteFile writes data to a file named by filename, atomically.
|
||||
//
|
||||
// It's a wrapper to ioutil.WriteFile, but provides atomicity (and increased
|
||||
// It's a wrapper to os.WriteFile, but provides atomicity (and increased
|
||||
// safety) by writing to a temporary file and renaming it at the end.
|
||||
//
|
||||
// Before the final rename, the given ops (if any) are called. They can be
|
||||
@@ -28,7 +27,7 @@ func WriteFile(filename string, data []byte, perm os.FileMode, ops ...FileOp) er
|
||||
// would have no expectation of Rename being atomic.
|
||||
// We make the file names start with "." so there's no confusion with the
|
||||
// originals.
|
||||
tmpf, err := ioutil.TempFile(path.Dir(filename), "."+path.Base(filename))
|
||||
tmpf, err := os.CreateTemp(path.Dir(filename), "."+path.Base(filename))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -19,7 +18,7 @@ func testWriteFile(fname string, data []byte, perm os.FileMode, ops ...FileOp) e
|
||||
}
|
||||
|
||||
// Read and compare the contents.
|
||||
c, err := ioutil.ReadFile(fname)
|
||||
c, err := os.ReadFile(fname)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user