refactor: move from io/ioutil to io and os package (#1843)

The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2021-10-07 12:37:42 +08:00
committed by GitHub
parent 4d4f1340db
commit 38cf7b0141
47 changed files with 189 additions and 207 deletions

View File

@@ -15,7 +15,6 @@ package cmd
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
@@ -837,12 +836,12 @@ func setupWithDefaults(flags map[string]interface{}, t *testing.T) *cobra.Comman
}
func tempFile(t *testing.T, contents string) string {
f, err := ioutil.TempFile("", "")
f, err := os.CreateTemp("", "")
Ok(t, err)
newName := f.Name() + ".yaml"
err = os.Rename(f.Name(), newName)
Ok(t, err)
ioutil.WriteFile(newName, []byte(contents), 0600) // nolint: errcheck
os.WriteFile(newName, []byte(contents), 0600) // nolint: errcheck
return newName
}