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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user