Skip to content

Commit 242dddf

Browse files
Gustedlunny
andauthored
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 <[email protected]>
1 parent 60b9455 commit 242dddf

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

models/asymkey/ssh_key_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package asymkey
77

88
import (
99
"bytes"
10-
"io/ioutil"
10+
"os"
1111
"os/exec"
1212
"path/filepath"
1313
"strings"
@@ -325,7 +325,7 @@ func TestFromOpenSSH(t *testing.T) {
325325
sigPath := dataPath + ".sig"
326326
run(t, nil, "ssh-keygen", "-Y", "sign", "-n", "file", "-f", privPath, dataPath)
327327

328-
sigBytes, err := ioutil.ReadFile(sigPath)
328+
sigBytes, err := os.ReadFile(sigPath)
329329
if err != nil {
330330
t.Fatal(err)
331331
}
@@ -467,7 +467,7 @@ func TestRoundTrip(t *testing.T) {
467467

468468
func write(t *testing.T, d []byte, fp ...string) string {
469469
p := filepath.Join(fp...)
470-
if err := ioutil.WriteFile(p, d, 0o600); err != nil {
470+
if err := os.WriteFile(p, d, 0o600); err != nil {
471471
t.Fatal(err)
472472
}
473473
return p

models/migrations/migrations_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"context"
99
"database/sql"
1010
"fmt"
11-
"io/ioutil"
1211
"os"
1312
"path"
1413
"path/filepath"
@@ -58,7 +57,7 @@ func TestMain(m *testing.M) {
5857
setting.CustomConf = giteaConf
5958
}
6059

61-
tmpDataPath, err := ioutil.TempDir("", "data")
60+
tmpDataPath, err := os.MkdirTemp("", "data")
6261
if err != nil {
6362
fmt.Printf("Unable to create temporary data path %v\n", err)
6463
os.Exit(1)

modules/updatechecker/update_checker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package updatechecker
66

77
import (
8-
"io/ioutil"
8+
"io"
99
"net/http"
1010

1111
"code.gitea.io/gitea/modules/appstate"
@@ -43,7 +43,7 @@ func GiteaUpdateChecker(httpEndpoint string) error {
4343
return err
4444
}
4545
defer resp.Body.Close()
46-
body, err := ioutil.ReadAll(resp.Body)
46+
body, err := io.ReadAll(resp.Body)
4747
if err != nil {
4848
return err
4949
}

0 commit comments

Comments
 (0)