1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-01-27 20:45:56 +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:
Alberto Bertogli
2022-11-12 20:02:52 +00:00
parent 008367d320
commit 3ebe5c5173
22 changed files with 42 additions and 61 deletions

View File

@@ -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
}