diff options
| author | Eric Biggers <ebiggers@google.com> | 2022-12-04 13:27:43 -0800 |
|---|---|---|
| committer | Eric Biggers <ebiggers3@gmail.com> | 2022-12-04 14:07:39 -0800 |
| commit | 02875cef9010633b6689cfd1e2ceec9107b756b4 (patch) | |
| tree | 9f310eac398e99dd12f42d94967b2e1bf1c7fe83 /filesystem/filesystem.go | |
| parent | 5373b314473b08f13372ab55b551738307a85fbd (diff) | |
Stop using deprecated package io/ioutil
Since Go 1.16 (which recently became the minimum supported Go version
for this project), the package io/ioutil is deprecated in favor of
equivalent functionality in the io and os packages. staticcheck warns
about this. Address all the warnings by switching to the non-deprecated
replacement functions.
Diffstat (limited to 'filesystem/filesystem.go')
| -rw-r--r-- | filesystem/filesystem.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 7852abb..0e1f0c8 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -35,7 +35,6 @@ package filesystem import ( "fmt" "io" - "io/ioutil" "log" "os" "os/user" @@ -335,7 +334,7 @@ func (m *Mount) PolicyPath(descriptor string) string { // directory and returns a temporary Mount which represents this temporary // directory. The caller is responsible for removing this temporary directory. func (m *Mount) tempMount() (*Mount, error) { - tempDir, err := ioutil.TempDir(filepath.Dir(m.BaseDir()), tempPrefix) + tempDir, err := os.MkdirTemp(filepath.Dir(m.BaseDir()), tempPrefix) return &Mount{Path: tempDir}, err } @@ -635,7 +634,7 @@ func (m *Mount) writeData(path string, data []byte, owner *user.User, mode os.Fi // Write the data to a temporary file, sync it, then rename into place // so that the operation will be atomic. dirPath := filepath.Dir(path) - tempFile, err := ioutil.TempFile(dirPath, tempPrefix) + tempFile, err := os.CreateTemp(dirPath, tempPrefix) if err != nil { log.Print(err) if os.IsPermission(err) { @@ -767,7 +766,7 @@ func readMetadataFileSafe(path string, trustedUser *user.User) ([]byte, int64, e } // Read the file contents, allowing at most maxMetadataFileSize bytes. reader := &io.LimitedReader{R: file, N: maxMetadataFileSize + 1} - data, err := ioutil.ReadAll(reader) + data, err := io.ReadAll(reader) if err != nil { return nil, -1, err } |