Remove deprecated io/ioutil (#15707)

This commit is contained in:
Klaus Post
2022-09-19 20:05:16 +02:00
committed by GitHub
parent 0b6175b742
commit ff12080ff5
89 changed files with 315 additions and 370 deletions

View File

@@ -24,7 +24,6 @@ import (
"flag"
"fmt"
"hash/crc32"
"io/ioutil"
"log"
"os"
"strings"
@@ -97,7 +96,7 @@ func main() {
if file != "" {
distrib := make([][]string, setCount)
b, err := ioutil.ReadFile(file)
b, err := os.ReadFile(file)
if err != nil {
log.Fatalln(err)
}

View File

@@ -22,7 +22,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"strings"
@@ -79,7 +79,7 @@ FLAGS:
return err
}
b, err := ioutil.ReadAll(r)
b, err := io.ReadAll(r)
if err != nil {
return err
}
@@ -105,7 +105,7 @@ FLAGS:
fmt.Println(string(b))
return nil
}
b, err := ioutil.ReadFile(file)
b, err := os.ReadFile(file)
if err != nil {
return err
}

View File

@@ -27,7 +27,6 @@ import (
"fmt"
"hash/crc32"
"io"
"io/ioutil"
"log"
"os"
"strings"
@@ -49,7 +48,7 @@ func main() {
File string `json:"file"`
Key string `json:"key"`
}{}
got, err := ioutil.ReadAll(os.Stdin)
got, err := io.ReadAll(os.Stdin)
if err != nil {
fatalErr(err)
}

View File

@@ -25,7 +25,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"strings"
@@ -80,7 +79,7 @@ FLAGS:
app.Action = func(c *cli.Context) error {
ndjson := c.Bool("ndjson")
decode := func(r io.Reader, file string) ([]byte, error) {
b, err := ioutil.ReadAll(r)
b, err := io.ReadAll(r)
if err != nil {
return nil, err
}
@@ -189,7 +188,7 @@ FLAGS:
}
}, file)
err := data.files(func(name string, data []byte) {
err = ioutil.WriteFile(fmt.Sprintf("%s-%s.data", file, name), data, os.ModePerm)
err = os.WriteFile(fmt.Sprintf("%s-%s.data", file, name), data, os.ModePerm)
if err != nil {
fmt.Println(err)
}

View File

@@ -23,7 +23,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"strings"
@@ -41,7 +41,7 @@ type Result struct {
}
func mainHandler(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
writeErrorResponse(w, err)
return

View File

@@ -24,7 +24,7 @@ import (
"context"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"net/url"
"os"
@@ -85,7 +85,7 @@ func main() {
if f, err := os.Open(sessionPolicyFile); err != nil {
log.Fatalf("Unable to open session policy file: %v", err)
} else {
bs, err := ioutil.ReadAll(f)
bs, err := io.ReadAll(f)
if err != nil {
log.Fatalf("Error reading session policy file: %v", err)
}

View File

@@ -24,7 +24,7 @@ import (
"context"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"net/url"
"os"
@@ -82,7 +82,7 @@ func main() {
if f, err := os.Open(sessionPolicyFile); err != nil {
log.Fatalf("Unable to open session policy file: %v", sessionPolicyFile, err)
} else {
bs, err := ioutil.ReadAll(f)
bs, err := io.ReadAll(f)
if err != nil {
log.Fatalf("Error reading session policy file: %v", err)
}