diff --git a/internal/dirs/dirs.go b/internal/dirs/dirs.go index 19707d4..ad37991 100644 --- a/internal/dirs/dirs.go +++ b/internal/dirs/dirs.go @@ -10,8 +10,8 @@ import ( const sep = string(os.PathSeparator) var ( - home string = os.Getenv("HOME") - pwd, _ = os.Getwd() + home = os.Getenv("HOME") + pwd, _ = os.Getwd() ) // UnExpand returns dir after expanding some directory shortcuts diff --git a/internal/files/files.go b/internal/files/files.go index 13f70a0..46b2f4b 100644 --- a/internal/files/files.go +++ b/internal/files/files.go @@ -27,9 +27,8 @@ func SortByModified(a, b File) int { return 1 } else if a.Date().After(b.Date()) { return -1 - } else { - return 0 } + return 0 } func SortByModifiedReverse(a, b File) int { @@ -37,9 +36,8 @@ func SortByModifiedReverse(a, b File) int { return 1 } else if a.Date().Before(b.Date()) { return -1 - } else { - return 0 } + return 0 } func SortBySize(a, b File) int { @@ -87,9 +85,8 @@ func SortDirectoriesFirst(a, b File) int { return 1 } else if a.IsDir() && !b.IsDir() { return -1 - } else { - return 0 } + return 0 } func SortDirectoriesLast(a, b File) int { @@ -97,9 +94,8 @@ func SortDirectoriesLast(a, b File) int { return 1 } else if !a.IsDir() && b.IsDir() { return -1 - } else { - return 0 } + return 0 } func doNameSort(a, b File) int { @@ -119,7 +115,6 @@ func doNameSort(a, b File) int { func getSortingSize(f File) int64 { if f.IsDir() { return -1 - } else { - return f.Filesize() } + return f.Filesize() } diff --git a/internal/files/trash.go b/internal/files/trash.go index 12e5d17..048bbc3 100644 --- a/internal/files/trash.go +++ b/internal/files/trash.go @@ -296,19 +296,19 @@ func ensureUniqueName(filename, trashDir string) (string, string) { // doesn't exist, so use it path := filepath.Join(filedir, filename) return info, path - } else { - // otherwise, try random suffixes until one works - log.Debugf("%s exists in trash, generating random name", filename) - var tries int - for { - tries++ - rando := randomFilename(randomStrLength) - newName := filepath.Join(infodir, filename+rando+trashInfoExt) - if _, err := os.Stat(newName); os.IsNotExist(err) { - path := filepath.Join(filedir, filename+rando) - log.Debugf("settled on random name %s%s on the %s try", filename, rando, humanize.Ordinal(tries)) - return newName, path - } + } + + // otherwise, try random suffixes until one works + log.Debugf("%s exists in trash, generating random name", filename) + var tries int + for { + tries++ + rando := randomFilename(randomStrLength) + newName := filepath.Join(infodir, filename+rando+trashInfoExt) + if _, err := os.Stat(newName); os.IsNotExist(err) { + path := filepath.Join(filedir, filename+rando) + log.Debugf("settled on random name %s%s on the %s try", filename, rando, humanize.Ordinal(tries)) + return newName, path } } } diff --git a/internal/interactive/interactive.go b/internal/interactive/interactive.go index 6a55043..d02a858 100644 --- a/internal/interactive/interactive.go +++ b/internal/interactive/interactive.go @@ -312,7 +312,6 @@ func (m model) View() string { } func (m model) showHelp() string { - // TODO: maybe use bubbletea built in help var filterText string if m.filter != "" { filterText = fmt.Sprintf(" (%s)", m.filter) diff --git a/internal/prompt/prompt.go b/internal/prompt/prompt.go index 78f864b..f57e511 100644 --- a/internal/prompt/prompt.go +++ b/internal/prompt/prompt.go @@ -11,8 +11,6 @@ import ( "golang.org/x/term" ) -// TODO: use charm stuff for this - func YesNo(prompt string) bool { return AskRune(prompt, "y/n") == 'y' } diff --git a/main.go b/main.go index 95e083d..e9477c5 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,4 @@ +// Package main does the thing package main import (