From 02875cef9010633b6689cfd1e2ceec9107b756b4 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 4 Dec 2022 13:27:43 -0800 Subject: 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. --- filesystem/filesystem.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'filesystem/filesystem.go') 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 } -- cgit v1.2.3