Skip to content

Commit fd66499

Browse files
Merge pull request #2167 from xiaoliwang/remove_deprecated
2 parents e001183 + 3d79c6a commit fd66499

File tree

21 files changed

+47
-57
lines changed

21 files changed

+47
-57
lines changed

pkg/app/daemon/daemon.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package daemon
22

33
import (
4-
"io/ioutil"
54
"log"
65
"os"
76
"path/filepath"
@@ -77,7 +76,7 @@ func (self *rebaseDaemon) Run() error {
7776
self.c.Log.Info("args: ", os.Args)
7877

7978
if strings.HasSuffix(os.Args[1], "git-rebase-todo") {
80-
if err := ioutil.WriteFile(os.Args[1], []byte(os.Getenv(RebaseTODOEnvKey)), 0o644); err != nil {
79+
if err := os.WriteFile(os.Args[1], []byte(os.Getenv(RebaseTODOEnvKey)), 0o644); err != nil {
8180
return err
8281
}
8382
} else if strings.HasSuffix(os.Args[1], filepath.Join(gitDir(), "COMMIT_EDITMSG")) { // TODO: test

pkg/app/logging.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package app
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"log"
66
"os"
77

@@ -26,7 +26,7 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
2626

2727
func newProductionLogger() *logrus.Logger {
2828
log := logrus.New()
29-
log.Out = ioutil.Discard
29+
log.Out = io.Discard
3030
log.SetLevel(logrus.ErrorLevel)
3131
return log
3232
}

pkg/cheatsheet/check.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cheatsheet
33
import (
44
"fmt"
55
"io/fs"
6-
"io/ioutil"
76
"log"
87
"os"
98
"path/filepath"
@@ -60,7 +59,7 @@ func obtainContent(dir string) string {
6059
content := ""
6160
err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
6261
if re.MatchString(path) {
63-
bytes, err := ioutil.ReadFile(path)
62+
bytes, err := os.ReadFile(path)
6463
if err != nil {
6564
log.Fatalf("Error occurred while checking if cheatsheets are up to date: %v", err)
6665
}

pkg/commands/git.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package commands
22

33
import (
4-
"io/ioutil"
54
"os"
65
"path/filepath"
76
"strings"
@@ -68,7 +67,7 @@ func NewGitCommand(
6867
return nil, err
6968
}
7069

71-
dotGitDir, err := findDotGitDir(os.Stat, ioutil.ReadFile)
70+
dotGitDir, err := findDotGitDir(os.Stat, os.ReadFile)
7271
if err != nil {
7372
return nil, err
7473
}

pkg/commands/git_commands/file.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package git_commands
22

33
import (
4-
"io/ioutil"
4+
"os"
55
"strconv"
66

77
"github.com/go-errors/errors"
@@ -20,7 +20,7 @@ func NewFileCommands(gitCommon *GitCommon) *FileCommands {
2020

2121
// Cat obtains the content of a file
2222
func (self *FileCommands) Cat(fileName string) (string, error) {
23-
buf, err := ioutil.ReadFile(fileName)
23+
buf, err := os.ReadFile(fileName)
2424
if err != nil {
2525
return "", nil
2626
}

pkg/commands/git_commands/rebase.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package git_commands
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"os"
66
"path/filepath"
77
"strings"
88

@@ -202,7 +202,7 @@ func (self *RebaseCommands) AmendTo(sha string) error {
202202
// EditRebaseTodo sets the action at a given index in the git-rebase-todo file
203203
func (self *RebaseCommands) EditRebaseTodo(index int, action string) error {
204204
fileName := filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo")
205-
bytes, err := ioutil.ReadFile(fileName)
205+
bytes, err := os.ReadFile(fileName)
206206
if err != nil {
207207
return err
208208
}
@@ -217,7 +217,7 @@ func (self *RebaseCommands) EditRebaseTodo(index int, action string) error {
217217
content[contentIndex] = action + " " + strings.Join(splitLine[1:], " ")
218218
result := strings.Join(content, "\n")
219219

220-
return ioutil.WriteFile(fileName, []byte(result), 0o644)
220+
return os.WriteFile(fileName, []byte(result), 0o644)
221221
}
222222

223223
func (self *RebaseCommands) getTodoCommitCount(content []string) int {
@@ -234,7 +234,7 @@ func (self *RebaseCommands) getTodoCommitCount(content []string) int {
234234
// MoveTodoDown moves a rebase todo item down by one position
235235
func (self *RebaseCommands) MoveTodoDown(index int) error {
236236
fileName := filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo")
237-
bytes, err := ioutil.ReadFile(fileName)
237+
bytes, err := os.ReadFile(fileName)
238238
if err != nil {
239239
return err
240240
}
@@ -247,7 +247,7 @@ func (self *RebaseCommands) MoveTodoDown(index int) error {
247247
rearrangedContent = append(rearrangedContent, content[contentIndex+1:]...)
248248
result := strings.Join(rearrangedContent, "\n")
249249

250-
return ioutil.WriteFile(fileName, []byte(result), 0o644)
250+
return os.WriteFile(fileName, []byte(result), 0o644)
251251
}
252252

253253
// SquashAllAboveFixupCommits squashes all fixup! commits above the given one

pkg/commands/git_commands/working_tree_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package git_commands
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"os"
66
"regexp"
77
"testing"
88

@@ -432,7 +432,7 @@ func TestWorkingTreeApplyPatch(t *testing.T) {
432432

433433
filename := matches[1]
434434

435-
content, err := ioutil.ReadFile(filename)
435+
content, err := os.ReadFile(filename)
436436
assert.NoError(t, err)
437437

438438
assert.Equal(t, "test", string(content))

pkg/commands/git_config/get_key.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package git_config
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"os/exec"
88
"strings"
99
"syscall"
@@ -38,7 +38,7 @@ import (
3838
func runGitConfigCmd(cmd *exec.Cmd) (string, error) {
3939
var stdout bytes.Buffer
4040
cmd.Stdout = &stdout
41-
cmd.Stderr = ioutil.Discard
41+
cmd.Stderr = io.Discard
4242

4343
err := cmd.Run()
4444
if exitError, ok := err.(*exec.ExitError); ok {

pkg/commands/loaders/commits.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package loaders
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"path/filepath"
98
"regexp"
@@ -50,7 +49,7 @@ func NewCommitLoader(
5049
cmd: cmd,
5150
getCurrentBranchName: getCurrentBranchName,
5251
getRebaseMode: getRebaseMode,
53-
readFile: ioutil.ReadFile,
52+
readFile: os.ReadFile,
5453
walkFiles: filepath.Walk,
5554
dotGitDir: dotGitDir,
5655
}

pkg/commands/oscommands/gui_io.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package oscommands
22

33
import (
44
"io"
5-
"io/ioutil"
65

76
"github.com/sirupsen/logrus"
87
)
@@ -45,7 +44,7 @@ func NewNullGuiIO(log *logrus.Entry) *guiIO {
4544
return &guiIO{
4645
log: log,
4746
logCommandFn: func(string, bool) {},
48-
newCmdWriterFn: func() io.Writer { return ioutil.Discard },
47+
newCmdWriterFn: func() io.Writer { return io.Discard },
4948
promptForCredentialFn: failPromptFn,
5049
}
5150
}

0 commit comments

Comments
 (0)