Skip to content

Commit

Permalink
deprecate ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Sep 22, 2022
1 parent 3be450f commit 6444527
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 3 additions & 4 deletions ecs-init/cache/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package cache

import (
"io"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -156,7 +155,7 @@ func (s *standardFS) MkdirAll(path string, perm os.FileMode) error {
}

func (s *standardFS) TempFile(dir, prefix string) (*os.File, error) {
return ioutil.TempFile(dir, prefix)
return os.CreateTemp(dir, prefix)
}

func (s *standardFS) Remove(path string) {
Expand All @@ -176,7 +175,7 @@ func (s *standardFS) Rename(oldpath, newpath string) error {
}

func (s *standardFS) ReadAll(r io.Reader) ([]byte, error) {
return ioutil.ReadAll(r)
return io.ReadAll(r)
}

func (s *standardFS) Open(name string) (io.ReadCloser, error) {
Expand All @@ -192,5 +191,5 @@ func (s *standardFS) Base(path string) string {
}

func (s *standardFS) WriteFile(filename string, data []byte, perm os.FileMode) error {
return ioutil.WriteFile(filename, data, perm)
return os.WriteFile(filename, data, perm)
}
3 changes: 1 addition & 2 deletions ecs-init/gpu/nvidia_gpu_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package gpu

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -219,5 +218,5 @@ func WriteToFile(filename string, data []byte, perm os.FileMode) error {
if err != nil {
return err
}
return ioutil.WriteFile(filename, data, perm)
return os.WriteFile(filename, data, perm)
}
5 changes: 2 additions & 3 deletions ecs-init/volumes/state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package volumes
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sync"
Expand Down Expand Up @@ -94,7 +93,7 @@ var saveStateToDisk = saveState
func saveState(b []byte) error {
// Make our temp-file on the same volume as our data-file to ensure we can
// actually move it atomically; cross-device renaming will error out
tmpfile, err := ioutil.TempFile(PluginStatePath, "tmp_ecs_volume_plugin")
tmpfile, err := os.CreateTemp(PluginStatePath, "tmp_ecs_volume_plugin")
if err != nil {
return fmt.Errorf("failed to create temp file: %v", err)
}
Expand Down Expand Up @@ -154,5 +153,5 @@ func (s *StateManager) load(a interface{}) error {
var readStateFile = readFile

func readFile() ([]byte, error) {
return ioutil.ReadFile(PluginStateFileAbsPath)
return os.ReadFile(PluginStateFileAbsPath)
}

0 comments on commit 6444527

Please sign in to comment.