Remove ioutil
(#18222)
- Don't use `ioutil` package anymore as it doesn't anything special anymore since Go 1.16: ``` // As of Go 1.16, the same functionality is now provided // by package io or package os, and those implementations // should be preferred in new code. ``` Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
60b945565d
commit
242dddfcb7
|
@ -7,7 +7,7 @@ package asymkey
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -325,7 +325,7 @@ func TestFromOpenSSH(t *testing.T) {
|
||||||
sigPath := dataPath + ".sig"
|
sigPath := dataPath + ".sig"
|
||||||
run(t, nil, "ssh-keygen", "-Y", "sign", "-n", "file", "-f", privPath, dataPath)
|
run(t, nil, "ssh-keygen", "-Y", "sign", "-n", "file", "-f", privPath, dataPath)
|
||||||
|
|
||||||
sigBytes, err := ioutil.ReadFile(sigPath)
|
sigBytes, err := os.ReadFile(sigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ func TestRoundTrip(t *testing.T) {
|
||||||
|
|
||||||
func write(t *testing.T, d []byte, fp ...string) string {
|
func write(t *testing.T, d []byte, fp ...string) string {
|
||||||
p := filepath.Join(fp...)
|
p := filepath.Join(fp...)
|
||||||
if err := ioutil.WriteFile(p, d, 0o600); err != nil {
|
if err := os.WriteFile(p, d, 0o600); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
return p
|
return p
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -58,7 +57,7 @@ func TestMain(m *testing.M) {
|
||||||
setting.CustomConf = giteaConf
|
setting.CustomConf = giteaConf
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpDataPath, err := ioutil.TempDir("", "data")
|
tmpDataPath, err := os.MkdirTemp("", "data")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Unable to create temporary data path %v\n", err)
|
fmt.Printf("Unable to create temporary data path %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
package updatechecker
|
package updatechecker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/appstate"
|
"code.gitea.io/gitea/modules/appstate"
|
||||||
|
@ -43,7 +43,7 @@ func GiteaUpdateChecker(httpEndpoint string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue