Handle ioutil deprecations (#53526)

* replace ioutil.ReadFile -> os.ReadFile

* replace ioutil.ReadAll -> io.ReadAll

* replace ioutil.TempFile -> os.CreateTemp

* replace ioutil.NopCloser -> io.NopCloser

* replace ioutil.WriteFile -> os.WriteFile

* replace ioutil.TempDir -> os.MkdirTemp

* replace ioutil.Discard -> io.Discard
This commit is contained in:
Jo
2022-08-10 15:37:51 +02:00
committed by GitHub
parent 4926767737
commit 062d255124
140 changed files with 462 additions and 492 deletions
+1 -2
View File
@@ -2,7 +2,6 @@ package setting
import (
"fmt"
"io/ioutil"
"os"
"regexp"
"sort"
@@ -145,7 +144,7 @@ func (e fileExpander) Expand(s string) (string, error) {
// nolint:gosec
// We can ignore the gosec G304 warning on this one because `s` comes from configuration section keys
f, err := ioutil.ReadFile(s)
f, err := os.ReadFile(s)
if err != nil {
return "", err
}
+1 -2
View File
@@ -3,7 +3,6 @@ package setting
import (
"errors"
"fmt"
"io/ioutil"
"math/rand"
"os"
"testing"
@@ -35,7 +34,7 @@ func TestExpandVar_EnvSuccessful(t *testing.T) {
}
func TestExpandVar_FileSuccessful(t *testing.T) {
f, err := ioutil.TempFile(os.TempDir(), "file expansion *")
f, err := os.CreateTemp(os.TempDir(), "file expansion *")
require.NoError(t, err)
file := f.Name()