Skip to content

Commit 3eceac3

Browse files
authored
Cleanup: remove ioutil for new go version (knative#5409)
Signed-off-by: xin.li <[email protected]>
1 parent be4f747 commit 3eceac3

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

code-samples/serving/multi-container/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You can do this by copying the following code into the `servingcontainer.go` fil
3939
package main
4040
import (
4141
"fmt"
42-
"io/ioutil"
42+
"io"
4343
"log"
4444
"net/http"
4545
)
@@ -49,7 +49,7 @@ You can do this by copying the following code into the `servingcontainer.go` fil
4949
if err != nil {
5050
log.Fatal(err)
5151
}
52-
resp, err := ioutil.ReadAll(res.Body)
52+
resp, err := io.ReadAll(res.Body)
5353
if err != nil {
5454
log.Fatal(err)
5555
}

code-samples/serving/multi-container/servingcontainer/servingcontainer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package main
1818

1919
import (
2020
"fmt"
21-
"io/ioutil"
21+
"io"
2222
"log"
2323
"net/http"
2424
)
@@ -29,7 +29,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
2929
if err != nil {
3030
log.Fatal(err)
3131
}
32-
resp, err := ioutil.ReadAll(res.Body)
32+
resp, err := io.ReadAll(res.Body)
3333
if err != nil {
3434
log.Fatal(err)
3535
}

docs/eventing/channels/generator/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package main
1818

1919
import (
2020
"flag"
21-
"io/ioutil"
2221
"log"
2322
"os"
2423
"sort"
@@ -42,7 +41,7 @@ func main() {
4241
}
4342

4443
func parseYaml() *yamlChannels {
45-
fileBytes, err := ioutil.ReadFile(*yamlFile)
44+
fileBytes, err := os.ReadFile(*yamlFile)
4645
if err != nil {
4746
log.Fatalf("Unable to read the YAML file '%s': %v", *yamlFile, err)
4847
}
@@ -79,7 +78,7 @@ type channel struct {
7978
}
8079

8180
func createTemplate() *template.Template {
82-
fileBytes, err := ioutil.ReadFile(*templateFile)
81+
fileBytes, err := os.ReadFile(*templateFile)
8382
if err != nil {
8483
log.Fatalf("Unable to read the template file '%s': %v", *templateFile, err)
8584
}

test/sampleapp/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package sampleapp
1818

1919
import (
2020
"fmt"
21-
"io/ioutil"
21+
"os"
2222

2323
yaml "gopkg.in/yaml.v2"
2424
)
@@ -60,7 +60,7 @@ func (lc *LanguageConfig) UseDefaultIfNotProvided() {
6060
// GetConfigs parses a config yaml file and return AllConfigs struct
6161
func GetConfigs(configPath string) (AllConfigs, error) {
6262
var lcs AllConfigs
63-
content, err := ioutil.ReadFile(configPath)
63+
content, err := os.ReadFile(configPath)
6464
if nil == err {
6565
err = yaml.Unmarshal(content, &lcs)
6666
}

0 commit comments

Comments
 (0)