all: Remove usage of deprecated io/ioutil (#7971)

As of Go 1.16 io/ioutil is deprecated. This replaces usage with the
corresponding functions in package os and package io.
This commit is contained in:
Jakob Borg
2021-11-22 08:59:47 +01:00
committed by GitHub
parent bf89bffb0b
commit 4b750b6dc3
71 changed files with 190 additions and 235 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"log"
"math"
"os"
@@ -108,7 +108,7 @@ func main() {
bs := readAll(htmlFile)
bs = authorsRe.ReplaceAll(bs, []byte("id=\"contributor-list\">\n"+replacement+"\n </div>"))
if err := ioutil.WriteFile(htmlFile, bs, 0644); err != nil {
if err := os.WriteFile(htmlFile, bs, 0644); err != nil {
log.Fatal(err)
}
@@ -173,7 +173,7 @@ func readAll(path string) []byte {
}
defer fd.Close()
bs, err := ioutil.ReadAll(fd)
bs, err := io.ReadAll(fd)
if err != nil {
log.Fatal(err)
}
+1 -2
View File
@@ -12,7 +12,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
@@ -31,7 +30,7 @@ func main() {
os.Exit(exitError)
}
bs, err := ioutil.ReadFile(os.Args[1])
bs, err := os.ReadFile(os.Args[1])
if err != nil {
fmt.Println("Reading input:", err)
os.Exit(exitError)
+1 -2
View File
@@ -16,7 +16,6 @@ import (
"fmt"
"go/format"
"io"
"io/ioutil"
"os"
"path/filepath"
"strconv"
@@ -74,7 +73,7 @@ func walkerFor(basePath string) filepath.WalkFunc {
}
if info.Mode().IsRegular() {
data, err := ioutil.ReadFile(name)
data, err := os.ReadFile(name)
if err != nil {
return err
}
+1 -2
View File
@@ -12,7 +12,6 @@ package main
import (
"bufio"
"flag"
"io/ioutil"
"log"
"os"
"os/exec"
@@ -51,7 +50,7 @@ func pruneInterfaceCheck(path string, size int64) error {
}
defer fd.Close()
tmp, err := ioutil.TempFile(".", "")
tmp, err := os.CreateTemp(".", "")
if err != nil {
return err
}
+2 -2
View File
@@ -12,7 +12,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
@@ -140,7 +140,7 @@ func loadValidLangs() []string {
log.Fatal(err)
}
defer fd.Close()
bs, err := ioutil.ReadAll(fd)
bs, err := io.ReadAll(fd)
if err != nil {
log.Fatal(err)
}