From 2558cf7fc7b50a534cc559c48f947ff8b9367943 Mon Sep 17 00:00:00 2001 From: Daniel Milde Date: Wed, 24 Apr 2024 10:17:23 +0200 Subject: [PATCH] refactor: gofumpted --- cmd/gdu/app/app.go | 9 ++-- cmd/gdu/main.go | 10 ++-- internal/common/ignore.go | 1 - internal/common/ignore_test.go | 2 +- internal/testdir/test_dir.go | 4 +- pkg/analyze/dir_linux_test.go | 4 +- pkg/analyze/dir_test.go | 6 +-- pkg/analyze/memory.go | 12 ++--- pkg/analyze/sequential_test.go | 6 +-- pkg/analyze/stored_test.go | 19 ++++++++ pkg/remove/parallel_linux_test.go | 4 +- pkg/remove/remove_linux_test.go | 2 +- report/export_test.go | 4 +- stdout/stdout_test.go | 8 ++-- tui/actions.go | 6 ++- tui/actions_test.go | 4 +- tui/exec_other.go | 76 +++++++++++++++---------------- tui/exec_windows.go | 66 +++++++++++++-------------- tui/export_test.go | 2 +- tui/keys_test.go | 8 ++-- 20 files changed, 137 insertions(+), 116 deletions(-) diff --git a/cmd/gdu/app/app.go b/cmd/gdu/app/app.go index f6def7423..416907706 100644 --- a/cmd/gdu/app/app.go +++ b/cmd/gdu/app/app.go @@ -4,14 +4,13 @@ import ( "fmt" "io" "io/fs" + "net/http" + "net/http/pprof" "os" "path/filepath" "runtime" "strings" - "net/http" - "net/http/pprof" - log "github.com/sirupsen/logrus" "github.com/dundee/gdu/v5/build" @@ -215,7 +214,7 @@ func (a *App) createUI() (UI, error) { if a.Flags.OutputFile == "-" { output = os.Stdout } else { - output, err = os.OpenFile(a.Flags.OutputFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + output, err = os.OpenFile(a.Flags.OutputFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600) if err != nil { return nil, fmt.Errorf("opening output file: %w", err) } @@ -357,7 +356,7 @@ func (a *App) runAction(ui UI, path string) error { if a.Flags.InputFile == "-" { input = os.Stdin } else { - input, err = os.OpenFile(a.Flags.InputFile, os.O_RDONLY, 0600) + input, err = os.OpenFile(a.Flags.InputFile, os.O_RDONLY, 0o600) if err != nil { return fmt.Errorf("opening input file: %w", err) } diff --git a/cmd/gdu/main.go b/cmd/gdu/main.go index f35e641fd..a842f1021 100644 --- a/cmd/gdu/main.go +++ b/cmd/gdu/main.go @@ -19,8 +19,10 @@ import ( "github.com/dundee/gdu/v5/pkg/device" ) -var af *app.Flags -var configErr error +var ( + af *app.Flags + configErr error +) var rootCmd = &cobra.Command{ Use: "gdu [directory_to_scan]", @@ -136,7 +138,7 @@ func runE(command *cobra.Command, args []string) error { if af.CfgFile == "" { setDefaultConfigFilePath() } - err = os.WriteFile(af.CfgFile, data, 0600) + err = os.WriteFile(af.CfgFile, data, 0o600) if err != nil { return fmt.Errorf("Error writing config file %s: %w", af.CfgFile, err) } @@ -150,7 +152,7 @@ func runE(command *cobra.Command, args []string) error { if af.LogFile == "-" { f = os.Stdout } else { - f, err = os.OpenFile(af.LogFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + f, err = os.OpenFile(af.LogFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600) if err != nil { return fmt.Errorf("opening log file: %w", err) } diff --git a/internal/common/ignore.go b/internal/common/ignore.go index 2ae1458b8..366b0598d 100644 --- a/internal/common/ignore.go +++ b/internal/common/ignore.go @@ -48,7 +48,6 @@ func (ui *UI) SetIgnoreFromFile(ignoreFile string) error { log.Printf("Reading ignoring dir patterns from file '%s'", ignoreFile) file, err := os.Open(ignoreFile) - if err != nil { return err } diff --git a/internal/common/ignore_test.go b/internal/common/ignore_test.go index 6638644b9..8ac5c6dbe 100644 --- a/internal/common/ignore_test.go +++ b/internal/common/ignore_test.go @@ -57,7 +57,7 @@ func TestIgnoreByPattern(t *testing.T) { } func TestIgnoreFromFile(t *testing.T) { - file, err := os.OpenFile("ignore", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + file, err := os.OpenFile("ignore", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600) if err != nil { panic(err) } diff --git a/internal/testdir/test_dir.go b/internal/testdir/test_dir.go index d6e3de662..0793921a0 100644 --- a/internal/testdir/test_dir.go +++ b/internal/testdir/test_dir.go @@ -10,10 +10,10 @@ func CreateTestDir() func() { if err := os.MkdirAll("test_dir/nested/subnested", os.ModePerm); err != nil { panic(err) } - if err := os.WriteFile("test_dir/nested/subnested/file", []byte("hello"), 0600); err != nil { + if err := os.WriteFile("test_dir/nested/subnested/file", []byte("hello"), 0o600); err != nil { panic(err) } - if err := os.WriteFile("test_dir/nested/file2", []byte("go"), 0600); err != nil { + if err := os.WriteFile("test_dir/nested/file2", []byte("go"), 0o600); err != nil { panic(err) } return func() { diff --git a/pkg/analyze/dir_linux_test.go b/pkg/analyze/dir_linux_test.go index 3fd2615ad..0ea7d23d1 100644 --- a/pkg/analyze/dir_linux_test.go +++ b/pkg/analyze/dir_linux_test.go @@ -19,7 +19,7 @@ func TestErr(t *testing.T) { err := os.Chmod("test_dir/nested", 0) assert.Nil(t, err) defer func() { - err = os.Chmod("test_dir/nested", 0755) + err = os.Chmod("test_dir/nested", 0o755) assert.Nil(t, err) }() @@ -45,7 +45,7 @@ func TestSeqErr(t *testing.T) { err := os.Chmod("test_dir/nested", 0) assert.Nil(t, err) defer func() { - err = os.Chmod("test_dir/nested", 0755) + err = os.Chmod("test_dir/nested", 0o755) assert.Nil(t, err) }() diff --git a/pkg/analyze/dir_test.go b/pkg/analyze/dir_test.go index 89f6f8608..f4de59191 100644 --- a/pkg/analyze/dir_test.go +++ b/pkg/analyze/dir_test.go @@ -83,7 +83,7 @@ func TestFlags(t *testing.T) { fin := testdir.CreateTestDir() defer fin() - err := os.Mkdir("test_dir/empty", 0644) + err := os.Mkdir("test_dir/empty", 0o644) assert.Nil(t, err) err = os.Symlink("test_dir/nested/file2", "test_dir/nested/file3") @@ -137,7 +137,7 @@ func TestFollowSymlink(t *testing.T) { fin := testdir.CreateTestDir() defer fin() - err := os.Mkdir("test_dir/empty", 0644) + err := os.Mkdir("test_dir/empty", 0o644) assert.Nil(t, err) err = os.Symlink("./file2", "test_dir/nested/file3") @@ -169,7 +169,7 @@ func TestBrokenSymlinkSkipped(t *testing.T) { fin := testdir.CreateTestDir() defer fin() - err := os.Mkdir("test_dir/empty", 0644) + err := os.Mkdir("test_dir/empty", 0o644) assert.Nil(t, err) err = os.Symlink("xxx", "test_dir/nested/file3") diff --git a/pkg/analyze/memory.go b/pkg/analyze/memory.go index 1bbda0b24..fdb1c5745 100644 --- a/pkg/analyze/memory.go +++ b/pkg/analyze/memory.go @@ -27,14 +27,14 @@ func manageMemoryUsage(c <-chan struct{}) { } /* - Try to balance performance and memory consumption. +Try to balance performance and memory consumption. - When less memory is used by gdu than the total free memory of the host, - Garbage Collection is disabled during the analysis phase at all. +When less memory is used by gdu than the total free memory of the host, +Garbage Collection is disabled during the analysis phase at all. - Otherwise GC is enabled. - The more memory is used and the less memory is free, - the more often will the GC happen. +Otherwise GC is enabled. +The more memory is used and the less memory is free, +the more often will the GC happen. */ func rebalanceGC(disabledGC *bool) { memStats := runtime.MemStats{} diff --git a/pkg/analyze/sequential_test.go b/pkg/analyze/sequential_test.go index a791e4ac1..b3e959263 100644 --- a/pkg/analyze/sequential_test.go +++ b/pkg/analyze/sequential_test.go @@ -83,7 +83,7 @@ func TestFlagsSeq(t *testing.T) { fin := testdir.CreateTestDir() defer fin() - err := os.Mkdir("test_dir/empty", 0644) + err := os.Mkdir("test_dir/empty", 0o644) assert.Nil(t, err) err = os.Symlink("test_dir/nested/file2", "test_dir/nested/file3") @@ -137,7 +137,7 @@ func TestFollowSymlinkSeq(t *testing.T) { fin := testdir.CreateTestDir() defer fin() - err := os.Mkdir("test_dir/empty", 0644) + err := os.Mkdir("test_dir/empty", 0o644) assert.Nil(t, err) err = os.Symlink("./file2", "test_dir/nested/file3") @@ -169,7 +169,7 @@ func TestBrokenSymlinkSkippedSeq(t *testing.T) { fin := testdir.CreateTestDir() defer fin() - err := os.Mkdir("test_dir/empty", 0644) + err := os.Mkdir("test_dir/empty", 0o644) assert.Nil(t, err) err = os.Symlink("xxx", "test_dir/nested/file3") diff --git a/pkg/analyze/stored_test.go b/pkg/analyze/stored_test.go index 108294209..fd69f5a80 100644 --- a/pkg/analyze/stored_test.go +++ b/pkg/analyze/stored_test.go @@ -117,6 +117,7 @@ func TestParentDirGetNamePanics(t *testing.T) { dir := &ParentDir{} dir.GetName() } + func TestParentDirGetFlagPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -126,6 +127,7 @@ func TestParentDirGetFlagPanics(t *testing.T) { dir := &ParentDir{} dir.GetFlag() } + func TestParentDirIsDirPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -135,6 +137,7 @@ func TestParentDirIsDirPanics(t *testing.T) { dir := &ParentDir{} dir.IsDir() } + func TestParentDirGetSizePanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -144,6 +147,7 @@ func TestParentDirGetSizePanics(t *testing.T) { dir := &ParentDir{} dir.GetSize() } + func TestParentDirGetTypePanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -153,6 +157,7 @@ func TestParentDirGetTypePanics(t *testing.T) { dir := &ParentDir{} dir.GetType() } + func TestParentDirGetUsagePanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -162,6 +167,7 @@ func TestParentDirGetUsagePanics(t *testing.T) { dir := &ParentDir{} dir.GetUsage() } + func TestParentDirGetMtimePanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -171,6 +177,7 @@ func TestParentDirGetMtimePanics(t *testing.T) { dir := &ParentDir{} dir.GetMtime() } + func TestParentDirGetItemCountPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -180,6 +187,7 @@ func TestParentDirGetItemCountPanics(t *testing.T) { dir := &ParentDir{} dir.GetItemCount() } + func TestParentDirGetParentPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -189,6 +197,7 @@ func TestParentDirGetParentPanics(t *testing.T) { dir := &ParentDir{} dir.GetParent() } + func TestParentDirSetParentPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -198,6 +207,7 @@ func TestParentDirSetParentPanics(t *testing.T) { dir := &ParentDir{} dir.SetParent(nil) } + func TestParentDirGetMultiLinkedInodePanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -207,6 +217,7 @@ func TestParentDirGetMultiLinkedInodePanics(t *testing.T) { dir := &ParentDir{} dir.GetMultiLinkedInode() } + func TestParentDirEncodeJSONPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -217,6 +228,7 @@ func TestParentDirEncodeJSONPanics(t *testing.T) { err := dir.EncodeJSON(nil, false) assert.NoError(t, err) } + func TestParentDirUpdateStatsPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -226,6 +238,7 @@ func TestParentDirUpdateStatsPanics(t *testing.T) { dir := &ParentDir{} dir.UpdateStats(nil) } + func TestParentDirAddFilePanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -235,6 +248,7 @@ func TestParentDirAddFilePanics(t *testing.T) { dir := &ParentDir{} dir.AddFile(nil) } + func TestParentDirGetFilesPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -244,6 +258,7 @@ func TestParentDirGetFilesPanics(t *testing.T) { dir := &ParentDir{} dir.GetFiles() } + func TestParentDirGetFilesLockedPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -253,6 +268,7 @@ func TestParentDirGetFilesLockedPanics(t *testing.T) { dir := &ParentDir{} dir.GetFilesLocked() } + func TestParentDirRLockPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -262,6 +278,7 @@ func TestParentDirRLockPanics(t *testing.T) { dir := &ParentDir{} dir.RLock() } + func TestParentDirSetFilesPanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -271,6 +288,7 @@ func TestParentDirSetFilesPanics(t *testing.T) { dir := &ParentDir{} dir.SetFiles(nil) } + func TestParentDirRemoveFilePanics(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -280,6 +298,7 @@ func TestParentDirRemoveFilePanics(t *testing.T) { dir := &ParentDir{} dir.RemoveFile(nil) } + func TestParentDirGetItemStatsPanics(t *testing.T) { defer func() { if r := recover(); r != nil { diff --git a/pkg/remove/parallel_linux_test.go b/pkg/remove/parallel_linux_test.go index 0f6e61ff7..fca34ef17 100644 --- a/pkg/remove/parallel_linux_test.go +++ b/pkg/remove/parallel_linux_test.go @@ -20,7 +20,7 @@ func TestRemoveItemFromDirParallelWithErr(t *testing.T) { err := os.Chmod("test_dir/nested", 0) assert.Nil(t, err) defer func() { - err = os.Chmod("test_dir/nested", 0755) + err = os.Chmod("test_dir/nested", 0o755) assert.Nil(t, err) }() @@ -49,7 +49,7 @@ func TestRemoveItemFromDirParallelWithErr2(t *testing.T) { err := os.Chmod("test_dir/nested/subnested", 0) assert.Nil(t, err) defer func() { - err = os.Chmod("test_dir/nested/subnested", 0755) + err = os.Chmod("test_dir/nested/subnested", 0o755) assert.Nil(t, err) }() diff --git a/pkg/remove/remove_linux_test.go b/pkg/remove/remove_linux_test.go index c09d85d53..19fc5036c 100644 --- a/pkg/remove/remove_linux_test.go +++ b/pkg/remove/remove_linux_test.go @@ -19,7 +19,7 @@ func TestRemoveFileWithErr(t *testing.T) { err := os.Chmod("test_dir/nested", 0) assert.Nil(t, err) defer func() { - err = os.Chmod("test_dir/nested", 0755) + err = os.Chmod("test_dir/nested", 0o755) assert.Nil(t, err) }() diff --git a/report/export_test.go b/report/export_test.go index f35778a9c..c1931cd41 100644 --- a/report/export_test.go +++ b/report/export_test.go @@ -74,7 +74,7 @@ func TestExportToFile(t *testing.T) { fin := testdir.CreateTestDir() defer fin() - reportOutput, err := os.OpenFile("output.json", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + reportOutput, err := os.OpenFile("output.json", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) assert.Nil(t, err) defer func() { os.Remove("output.json") @@ -89,7 +89,7 @@ func TestExportToFile(t *testing.T) { err = ui.StartUILoop() assert.Nil(t, err) - reportOutput, err = os.OpenFile("output.json", os.O_RDONLY, 0644) + reportOutput, err = os.OpenFile("output.json", os.O_RDONLY, 0o644) assert.Nil(t, err) _, err = reportOutput.Seek(0, 0) assert.Nil(t, err) diff --git a/stdout/stdout_test.go b/stdout/stdout_test.go index 2146367da..240ed1326 100644 --- a/stdout/stdout_test.go +++ b/stdout/stdout_test.go @@ -149,7 +149,7 @@ func TestShowDevicesWithColor(t *testing.T) { } func TestReadAnalysisWithColor(t *testing.T) { - input, err := os.OpenFile("../internal/testdata/test.json", os.O_RDONLY, 0644) + input, err := os.OpenFile("../internal/testdata/test.json", os.O_RDONLY, 0o644) assert.Nil(t, err) output := bytes.NewBuffer(make([]byte, 10)) @@ -162,7 +162,7 @@ func TestReadAnalysisWithColor(t *testing.T) { } func TestReadAnalysisBw(t *testing.T) { - input, err := os.OpenFile("../internal/testdata/test.json", os.O_RDONLY, 0644) + input, err := os.OpenFile("../internal/testdata/test.json", os.O_RDONLY, 0o644) assert.Nil(t, err) output := bytes.NewBuffer(make([]byte, 10)) @@ -175,7 +175,7 @@ func TestReadAnalysisBw(t *testing.T) { } func TestReadAnalysisWithWrongFile(t *testing.T) { - input, err := os.OpenFile("../internal/testdata/wrong.json", os.O_RDONLY, 0644) + input, err := os.OpenFile("../internal/testdata/wrong.json", os.O_RDONLY, 0o644) assert.Nil(t, err) output := bytes.NewBuffer(make([]byte, 10)) @@ -187,7 +187,7 @@ func TestReadAnalysisWithWrongFile(t *testing.T) { } func TestReadAnalysisWithSummarize(t *testing.T) { - input, err := os.OpenFile("../internal/testdata/test.json", os.O_RDONLY, 0644) + input, err := os.OpenFile("../internal/testdata/test.json", os.O_RDONLY, 0o644) assert.Nil(t, err) output := bytes.NewBuffer(make([]byte, 10)) diff --git a/tui/actions.go b/tui/actions.go index 5ca16ee75..92347e711 100644 --- a/tui/actions.go +++ b/tui/actions.go @@ -22,8 +22,10 @@ import ( "github.com/rivo/tview" ) -const defaultLinesCount = 500 -const linesTreshold = 20 +const ( + defaultLinesCount = 500 + linesTreshold = 20 +) // ListDevices lists mounted devices and shows their disk usage func (ui *UI) ListDevices(getter device.DevicesInfoGetter) error { diff --git a/tui/actions_test.go b/tui/actions_test.go index b4d2af049..8c5e266db 100644 --- a/tui/actions_test.go +++ b/tui/actions_test.go @@ -152,7 +152,7 @@ func TestReadAnalysis(t *testing.T) { simScreen := testapp.CreateSimScreen() defer simScreen.Fini() - input, err := os.OpenFile("../internal/testdata/test.json", os.O_RDONLY, 0644) + input, err := os.OpenFile("../internal/testdata/test.json", os.O_RDONLY, 0o644) assert.Nil(t, err) app := testapp.CreateMockedApp(true) @@ -175,7 +175,7 @@ func TestReadAnalysisWithWrongFile(t *testing.T) { simScreen := testapp.CreateSimScreen() defer simScreen.Fini() - input, err := os.OpenFile("../internal/testdata/wrong.json", os.O_RDONLY, 0644) + input, err := os.OpenFile("../internal/testdata/wrong.json", os.O_RDONLY, 0o644) assert.Nil(t, err) app := testapp.CreateMockedApp(true) diff --git a/tui/exec_other.go b/tui/exec_other.go index 6fd0b91b7..e05e4e5f4 100644 --- a/tui/exec_other.go +++ b/tui/exec_other.go @@ -1,38 +1,38 @@ -//go:build !windows -// +build !windows - -package tui - -import ( - "os" - "syscall" -) - -func getShellBin() string { - shellbin, ok := os.LookupEnv("SHELL") - if !ok { - shellbin = "/bin/bash" - } - return shellbin -} - -func (ui *UI) spawnShell() { - if ui.currentDir == nil { - return - } - - ui.app.Suspend(func() { - if err := os.Chdir(ui.currentDirPath); err != nil { - ui.showErr("Error changing directory", err) - return - } - - if err := ui.exec(getShellBin(), nil, os.Environ()); err != nil { - ui.showErr("Error executing shell", err) - } - }) -} - -func stopProcess() error { - return syscall.Kill(syscall.Getpid(), syscall.SIGTSTP) -} +//go:build !windows +// +build !windows + +package tui + +import ( + "os" + "syscall" +) + +func getShellBin() string { + shellbin, ok := os.LookupEnv("SHELL") + if !ok { + shellbin = "/bin/bash" + } + return shellbin +} + +func (ui *UI) spawnShell() { + if ui.currentDir == nil { + return + } + + ui.app.Suspend(func() { + if err := os.Chdir(ui.currentDirPath); err != nil { + ui.showErr("Error changing directory", err) + return + } + + if err := ui.exec(getShellBin(), nil, os.Environ()); err != nil { + ui.showErr("Error executing shell", err) + } + }) +} + +func stopProcess() error { + return syscall.Kill(syscall.Getpid(), syscall.SIGTSTP) +} diff --git a/tui/exec_windows.go b/tui/exec_windows.go index def10f0c6..93eb31b7c 100644 --- a/tui/exec_windows.go +++ b/tui/exec_windows.go @@ -1,33 +1,33 @@ -package tui - -import ( - "os" -) - -func getShellBin() string { - shellbin, ok := os.LookupEnv("COMSPEC") - if !ok { - shellbin = "C:\\WINDOWS\\System32\\cmd.exe" - } - return shellbin -} - -func (ui *UI) spawnShell() { - if ui.currentDir == nil { - return - } - - ui.app.Stop() - - if err := os.Chdir(ui.currentDirPath); err != nil { - ui.showErr("Error changing directory", err) - return - } - if err := ui.exec(getShellBin(), nil, os.Environ()); err != nil { - ui.showErr("Error executing shell", err) - } -} - -func stopProcess() error { - return nil -} +package tui + +import ( + "os" +) + +func getShellBin() string { + shellbin, ok := os.LookupEnv("COMSPEC") + if !ok { + shellbin = "C:\\WINDOWS\\System32\\cmd.exe" + } + return shellbin +} + +func (ui *UI) spawnShell() { + if ui.currentDir == nil { + return + } + + ui.app.Stop() + + if err := os.Chdir(ui.currentDirPath); err != nil { + ui.showErr("Error changing directory", err) + return + } + if err := ui.exec(getShellBin(), nil, os.Environ()); err != nil { + ui.showErr("Error executing shell", err) + } +} + +func stopProcess() error { + return nil +} diff --git a/tui/export_test.go b/tui/export_test.go index 52fd22cc7..b7fae0b9b 100644 --- a/tui/export_test.go +++ b/tui/export_test.go @@ -175,7 +175,7 @@ func TestExportAnalysisWithoutRights(t *testing.T) { err = os.Chmod("export.json", 0) assert.NoError(t, err) defer func() { - err = os.Chmod("export.json", 0755) + err = os.Chmod("export.json", 0o755) assert.Nil(t, err) err = os.Remove("export.json") assert.NoError(t, err) diff --git a/tui/keys_test.go b/tui/keys_test.go index cb7baa820..7b352c4ad 100644 --- a/tui/keys_test.go +++ b/tui/keys_test.go @@ -217,7 +217,7 @@ func TestSpawnShell(t *testing.T) { app := testapp.CreateMockedApp(false) buff := &bytes.Buffer{} ui := CreateUI(app, simScreen, buff, true, true, false, false, false) - var called = false + called := false ui.exec = func(argv0 string, argv, envv []string) error { called = true return nil @@ -247,7 +247,7 @@ func TestSpawnShellWithoutDir(t *testing.T) { app := testapp.CreateMockedApp(false) buff := &bytes.Buffer{} ui := CreateUI(app, simScreen, buff, true, true, false, false, false) - var called = false + called := false ui.exec = func(argv0 string, argv, envv []string) error { called = true return nil @@ -269,7 +269,7 @@ func TestSpawnShellWithWrongDir(t *testing.T) { app := testapp.CreateMockedApp(false) buff := &bytes.Buffer{} ui := CreateUI(app, simScreen, buff, true, true, false, false, false) - var called = false + called := false ui.exec = func(argv0 string, argv, envv []string) error { called = true return nil @@ -294,7 +294,7 @@ func TestSpawnShellWithError(t *testing.T) { app := testapp.CreateMockedApp(false) buff := &bytes.Buffer{} ui := CreateUI(app, simScreen, buff, true, true, false, false, false) - var called = false + called := false ui.exec = func(argv0 string, argv, envv []string) error { called = true return errors.New("wrong shell")