From 3eceac37a3ca7b4e3523f29470ce6005c1ae1997 Mon Sep 17 00:00:00 2001 From: my-git9 Date: Wed, 8 Feb 2023 21:43:47 +0800 Subject: [PATCH] Cleanup: remove ioutil for new go version (#5409) Signed-off-by: xin.li --- code-samples/serving/multi-container/README.md | 4 ++-- .../multi-container/servingcontainer/servingcontainer.go | 4 ++-- docs/eventing/channels/generator/main.go | 5 ++--- test/sampleapp/config.go | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/code-samples/serving/multi-container/README.md b/code-samples/serving/multi-container/README.md index a2ff6889d..b49700e62 100644 --- a/code-samples/serving/multi-container/README.md +++ b/code-samples/serving/multi-container/README.md @@ -39,7 +39,7 @@ You can do this by copying the following code into the `servingcontainer.go` fil package main import ( "fmt" - "io/ioutil" + "io" "log" "net/http" ) @@ -49,7 +49,7 @@ You can do this by copying the following code into the `servingcontainer.go` fil if err != nil { log.Fatal(err) } - resp, err := ioutil.ReadAll(res.Body) + resp, err := io.ReadAll(res.Body) if err != nil { log.Fatal(err) } diff --git a/code-samples/serving/multi-container/servingcontainer/servingcontainer.go b/code-samples/serving/multi-container/servingcontainer/servingcontainer.go index f469e4bf4..45efa5ff7 100644 --- a/code-samples/serving/multi-container/servingcontainer/servingcontainer.go +++ b/code-samples/serving/multi-container/servingcontainer/servingcontainer.go @@ -18,7 +18,7 @@ package main import ( "fmt" - "io/ioutil" + "io" "log" "net/http" ) @@ -29,7 +29,7 @@ func handler(w http.ResponseWriter, r *http.Request) { if err != nil { log.Fatal(err) } - resp, err := ioutil.ReadAll(res.Body) + resp, err := io.ReadAll(res.Body) if err != nil { log.Fatal(err) } diff --git a/docs/eventing/channels/generator/main.go b/docs/eventing/channels/generator/main.go index d9b0560ef..c8d170c60 100644 --- a/docs/eventing/channels/generator/main.go +++ b/docs/eventing/channels/generator/main.go @@ -18,7 +18,6 @@ package main import ( "flag" - "io/ioutil" "log" "os" "sort" @@ -42,7 +41,7 @@ func main() { } func parseYaml() *yamlChannels { - fileBytes, err := ioutil.ReadFile(*yamlFile) + fileBytes, err := os.ReadFile(*yamlFile) if err != nil { log.Fatalf("Unable to read the YAML file '%s': %v", *yamlFile, err) } @@ -79,7 +78,7 @@ type channel struct { } func createTemplate() *template.Template { - fileBytes, err := ioutil.ReadFile(*templateFile) + fileBytes, err := os.ReadFile(*templateFile) if err != nil { log.Fatalf("Unable to read the template file '%s': %v", *templateFile, err) } diff --git a/test/sampleapp/config.go b/test/sampleapp/config.go index 92d2498c0..20ca10e62 100644 --- a/test/sampleapp/config.go +++ b/test/sampleapp/config.go @@ -18,7 +18,7 @@ package sampleapp import ( "fmt" - "io/ioutil" + "os" yaml "gopkg.in/yaml.v2" ) @@ -60,7 +60,7 @@ func (lc *LanguageConfig) UseDefaultIfNotProvided() { // GetConfigs parses a config yaml file and return AllConfigs struct func GetConfigs(configPath string) (AllConfigs, error) { var lcs AllConfigs - content, err := ioutil.ReadFile(configPath) + content, err := os.ReadFile(configPath) if nil == err { err = yaml.Unmarshal(content, &lcs) }