From 2dda39dff03859b145b0c229a15cf287eb1f495d Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 9 Oct 2023 22:02:53 +1100 Subject: [PATCH] Appease linter --- pkg/commands/dummies.go | 4 ++-- pkg/commands/os.go | 6 +++--- pkg/commands/os_test.go | 3 +-- pkg/commands/ssh/ssh.go | 3 +-- pkg/config/app_config.go | 3 +-- pkg/gui/subprocess.go | 6 +++--- pkg/log/log.go | 4 ++-- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/pkg/commands/dummies.go b/pkg/commands/dummies.go index 416a57dd..552171ac 100644 --- a/pkg/commands/dummies.go +++ b/pkg/commands/dummies.go @@ -1,7 +1,7 @@ package commands import ( - "io/ioutil" + "io" "github.com/jesseduffield/lazydocker/pkg/config" "github.com/jesseduffield/lazydocker/pkg/i18n" @@ -31,7 +31,7 @@ func NewDummyAppConfig() *config.AppConfig { // NewDummyLog creates a new dummy Log for testing func NewDummyLog() *logrus.Entry { log := logrus.New() - log.Out = ioutil.Discard + log.Out = io.Discard return log.WithField("test", "test") } diff --git a/pkg/commands/os.go b/pkg/commands/os.go index 259f782b..b8dec4a0 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -3,7 +3,7 @@ package commands import ( "context" "fmt" - "io/ioutil" + "io" "os" "os/exec" "path/filepath" @@ -240,7 +240,7 @@ func (c *OSCommand) AppendLineToFile(filename, line string) error { // CreateTempFile writes a string to a new temp file and returns the file's name func (c *OSCommand) CreateTempFile(filename, content string) (string, error) { - tmpfile, err := ioutil.TempFile("", filename) + tmpfile, err := os.CreateTemp("", filename) if err != nil { c.Log.Error(err) return "", WrapError(err) @@ -342,7 +342,7 @@ func (c *OSCommand) PipeCommands(commandStrings ...string) error { c.Log.Error(err) } - if b, err := ioutil.ReadAll(stderr); err == nil { + if b, err := io.ReadAll(stderr); err == nil { if len(b) > 0 { finalErrors = append(finalErrors, string(b)) } diff --git a/pkg/commands/os_test.go b/pkg/commands/os_test.go index 92be790a..3e036db4 100644 --- a/pkg/commands/os_test.go +++ b/pkg/commands/os_test.go @@ -2,7 +2,6 @@ package commands import ( "fmt" - "io/ioutil" "os" "os/exec" "testing" @@ -290,7 +289,7 @@ func TestOSCommandCreateTempFile(t *testing.T) { func(path string, err error) { assert.NoError(t, err) - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) assert.NoError(t, err) assert.Equal(t, "content", string(content)) diff --git a/pkg/commands/ssh/ssh.go b/pkg/commands/ssh/ssh.go index 9f572683..ecc84045 100644 --- a/pkg/commands/ssh/ssh.go +++ b/pkg/commands/ssh/ssh.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "net" "net/url" "os" @@ -37,7 +36,7 @@ func NewSSHHandler(oSCommand CmdKiller) *SSHHandler { return (&net.Dialer{}).DialContext(ctx, network, addr) }, startCmd: func(cmd *exec.Cmd) error { return cmd.Start() }, - tempDir: ioutil.TempDir, + tempDir: os.MkdirTemp, getenv: os.Getenv, setenv: os.Setenv, } diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index f3a47db2..d35a244d 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -13,7 +13,6 @@ package config import ( - "io/ioutil" "os" "path/filepath" "strings" @@ -569,7 +568,7 @@ func loadUserConfig(configDir string, base *UserConfig) (*UserConfig, error) { } } - content, err := ioutil.ReadFile(fileName) + content, err := os.ReadFile(fileName) if err != nil { return nil, err } diff --git a/pkg/gui/subprocess.go b/pkg/gui/subprocess.go index 62003390..b41ac475 100644 --- a/pkg/gui/subprocess.go +++ b/pkg/gui/subprocess.go @@ -2,7 +2,7 @@ package gui import ( "fmt" - "io/ioutil" + "io" "os" "os/exec" "os/signal" @@ -65,8 +65,8 @@ func (gui *Gui) runCommand(cmd *exec.Cmd, msg string) { } cmd.Stdin = nil - cmd.Stdout = ioutil.Discard - cmd.Stderr = ioutil.Discard + cmd.Stdout = io.Discard + cmd.Stderr = io.Discard gui.promptToReturn() } diff --git a/pkg/log/log.go b/pkg/log/log.go index e80cadc7..232a7bb8 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -2,7 +2,7 @@ package log import ( "fmt" - "io/ioutil" + "io" "os" "path/filepath" @@ -54,7 +54,7 @@ func newDevelopmentLogger(config *config.AppConfig) *logrus.Logger { func newProductionLogger() *logrus.Logger { log := logrus.New() - log.Out = ioutil.Discard + log.Out = io.Discard log.SetLevel(logrus.ErrorLevel) return log }