io/ioutil has already been deprecated in golang 1.16, so replace all ioutil with io and os

This commit is contained in:
ahrtr
2021-10-30 06:41:02 +08:00
parent 2d0fa78f2f
commit fe95aa614c
96 changed files with 250 additions and 297 deletions

View File

@@ -20,8 +20,8 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"math"
"os"
"strings"
"sync"
"testing"
@@ -542,7 +542,7 @@ func BenchmarkPerfScheduling(b *testing.B) {
}
func loadSchedulerConfig(file string) (*config.KubeSchedulerConfiguration, error) {
data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
return nil, err
}
@@ -940,7 +940,7 @@ func waitUntilPodsScheduled(ctx context.Context, podInformer coreinformers.PodIn
}
func getSpecFromFile(path *string, spec interface{}) error {
bytes, err := ioutil.ReadFile(*path)
bytes, err := os.ReadFile(*path)
if err != nil {
return err
}
@@ -948,7 +948,7 @@ func getSpecFromFile(path *string, spec interface{}) error {
}
func getUnstructuredFromFile(path string) (*unstructured.Unstructured, *schema.GroupVersionKind, error) {
bytes, err := ioutil.ReadFile(path)
bytes, err := os.ReadFile(path)
if err != nil {
return nil, nil, err
}

View File

@@ -22,7 +22,6 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"math"
"os"
"path"
@@ -178,7 +177,7 @@ func dataItems2JSONFile(dataItems DataItems, namePrefix string) error {
if err := json.Indent(formatted, b, "", " "); err != nil {
return fmt.Errorf("indenting error: %v", err)
}
return ioutil.WriteFile(destFile, formatted.Bytes(), 0644)
return os.WriteFile(destFile, formatted.Bytes(), 0644)
}
type labelValues struct {