mirror of https://github.com/knative/docs.git
Cleanup: remove ioutil for new go version (#5409)
Signed-off-by: xin.li <xin.li@daocloud.io>
This commit is contained in:
parent
be4f747329
commit
3eceac37a3
|
@ -39,7 +39,7 @@ You can do this by copying the following code into the `servingcontainer.go` fil
|
||||||
package main
|
package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -49,7 +49,7 @@ You can do this by copying the following code into the `servingcontainer.go` fil
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
resp, err := ioutil.ReadAll(res.Body)
|
resp, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
resp, err := ioutil.ReadAll(res.Body)
|
resp, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -42,7 +41,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseYaml() *yamlChannels {
|
func parseYaml() *yamlChannels {
|
||||||
fileBytes, err := ioutil.ReadFile(*yamlFile)
|
fileBytes, err := os.ReadFile(*yamlFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Unable to read the YAML file '%s': %v", *yamlFile, err)
|
log.Fatalf("Unable to read the YAML file '%s': %v", *yamlFile, err)
|
||||||
}
|
}
|
||||||
|
@ -79,7 +78,7 @@ type channel struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTemplate() *template.Template {
|
func createTemplate() *template.Template {
|
||||||
fileBytes, err := ioutil.ReadFile(*templateFile)
|
fileBytes, err := os.ReadFile(*templateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Unable to read the template file '%s': %v", *templateFile, err)
|
log.Fatalf("Unable to read the template file '%s': %v", *templateFile, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ package sampleapp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
@ -60,7 +60,7 @@ func (lc *LanguageConfig) UseDefaultIfNotProvided() {
|
||||||
// GetConfigs parses a config yaml file and return AllConfigs struct
|
// GetConfigs parses a config yaml file and return AllConfigs struct
|
||||||
func GetConfigs(configPath string) (AllConfigs, error) {
|
func GetConfigs(configPath string) (AllConfigs, error) {
|
||||||
var lcs AllConfigs
|
var lcs AllConfigs
|
||||||
content, err := ioutil.ReadFile(configPath)
|
content, err := os.ReadFile(configPath)
|
||||||
if nil == err {
|
if nil == err {
|
||||||
err = yaml.Unmarshal(content, &lcs)
|
err = yaml.Unmarshal(content, &lcs)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue