ioutil deprecated

This commit is contained in:
techknowlogick 2023-09-07 21:22:41 -04:00
parent 612362e3a1
commit 243ceb77f1
6 changed files with 11 additions and 13 deletions

View file

@ -5,7 +5,7 @@ package cmd
import (
"fmt"
"io/ioutil"
"io"
"strings"
"code.gitea.io/tea/cmd/flags"
@ -49,7 +49,7 @@ func runAddComment(cmd *cli.Context) error {
body := strings.Join(ctx.Args().Tail(), " ")
if interact.IsStdinPiped() {
// custom solution until https://github.com/AlecAivazis/survey/issues/328 is fixed
if bodyStdin, err := ioutil.ReadAll(ctx.App.Reader); err != nil {
if bodyStdin, err := io.ReadAll(ctx.App.Reader); err != nil {
return err
} else if len(bodyStdin) != 0 {
body = strings.Join([]string{body, string(bodyStdin)}, "\n\n")

View file

@ -5,8 +5,8 @@ package config
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"sync"
@ -83,7 +83,7 @@ func loadConfig() (err error) {
ymlPath := GetConfigPath()
exist, _ := utils.FileExist(ymlPath)
if exist {
bs, err := ioutil.ReadFile(ymlPath)
bs, err := os.ReadFile(ymlPath)
if err != nil {
err = fmt.Errorf("Failed to read config file: %s", ymlPath)
}
@ -104,5 +104,5 @@ func saveConfig() error {
if err != nil {
return err
}
return ioutil.WriteFile(ymlPath, bs, 0o660)
return os.WriteFile(ymlPath, bs, 0o660)
}

View file

@ -5,7 +5,6 @@ package git
import (
"fmt"
"io/ioutil"
"net/url"
"code.gitea.io/tea/modules/utils"
@ -52,7 +51,7 @@ func readSSHPrivKey(keyFile string, passwordCallback pwCallback) (sig ssh.Signer
if err != nil {
return nil, err
}
sshKey, err := ioutil.ReadFile(keyFile)
sshKey, err := io.ReadFile(keyFile)
if err != nil {
return nil, fmt.Errorf("can not read ssh key '%s'", keyFile)
}

View file

@ -4,7 +4,7 @@
package task
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -63,7 +63,7 @@ func getLocalKeys() []string {
// parse each local key with present privkey & compare fingerprints to online keys
for _, pubkeyPath := range localPubkeyPaths {
var pubkeyFile []byte
pubkeyFile, err = ioutil.ReadFile(pubkeyPath)
pubkeyFile, err = os.ReadFile(pubkeyPath)
if err != nil {
continue
}

View file

@ -5,7 +5,7 @@ package task
import (
"encoding/base64"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -39,7 +39,7 @@ func findSSHKey(client *gitea.Client) (string, error) {
// parse each local key with present privkey & compare fingerprints to online keys
for _, pubkeyPath := range localPubkeyPaths {
var pubkeyFile []byte
pubkeyFile, err = ioutil.ReadFile(pubkeyPath)
pubkeyFile, err = os.ReadFile(pubkeyPath)
if err != nil {
continue
}

View file

@ -5,7 +5,6 @@ package task
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
@ -52,7 +51,7 @@ func SavePullDiff(ctx *context.TeaContext, idx int64) (string, error) {
if err != nil {
return "", err
}
writer, err := ioutil.TempFile(os.TempDir(), fmt.Sprintf("pull-%d-review-*.diff", idx))
writer, err := os.CreateTemp(os.TempDir(), fmt.Sprintf("pull-%d-review-*.diff", idx))
if err != nil {
return "", err
}