diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-03-15 11:50:22 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-03-15 11:50:22 +0300 |
| commit | e47657533453270565caa5e94cfa59307d2a7970 (patch) | |
| tree | 30fae510369e8d86c65f613302d08fc2221d10eb /tools/chain.go | |
| parent | 7e346b5e1971c21d24945c2f09c60b7463a619d1 (diff) | |
Chore: linter complaints
Diffstat (limited to 'tools/chain.go')
| -rw-r--r-- | tools/chain.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/chain.go b/tools/chain.go index b94d2f8..8a79eda 100644 --- a/tools/chain.go +++ b/tools/chain.go @@ -1,10 +1,12 @@ package tools import ( + "errors" "fmt" "os" "os/exec" "path/filepath" + "strconv" "strings" ) @@ -143,7 +145,7 @@ func ExecChain(command string) string { func execSingle(command, stdin string) (string, error) { parts := tokenize(command) if len(parts) == 0 { - return "", fmt.Errorf("empty command") + return "", errors.New("empty command") } name := parts[0] args := parts[1:] @@ -243,10 +245,10 @@ func execBuiltin(name string, args []string, stdin string) string { return fmt.Sprintf("[error] cd: %v", err) } if !info.IsDir() { - return fmt.Sprintf("[error] cd: not a directory: %s", dir) + return "[error] cd: not a directory: " + dir } cfg.FilePickerDir = abs - return fmt.Sprintf("Changed directory to: %s", cfg.FilePickerDir) + return "Changed directory to: " + cfg.FilePickerDir case "mkdir": if len(args) == 0 { return "[error] usage: mkdir [-p] <dir>" @@ -278,9 +280,9 @@ func execBuiltin(name string, args []string, stdin string) string { return fmt.Sprintf("[error] mkdir: %v", err) } if createParents { - return fmt.Sprintf("Created %s (with parents)", dirPath) + return "Created " + dirPath + " (with parents)" } - return fmt.Sprintf("Created %s", dirPath) + return "Created " + dirPath case "ls": dir := "." for _, a := range args { @@ -300,16 +302,17 @@ func execBuiltin(name string, args []string, stdin string) string { var out strings.Builder for _, e := range entries { info, _ := e.Info() - if e.IsDir() { + switch { + case e.IsDir(): fmt.Fprintf(&out, "d %-8s %s/\n", "-", e.Name()) - } else if info != nil { + case info != nil: size := info.Size() - sizeStr := fmt.Sprintf("%d", size) + sizeStr := strconv.FormatInt(size, 10) if size > 1024 { sizeStr = fmt.Sprintf("%.1fKB", float64(size)/1024) } fmt.Fprintf(&out, "f %-8s %s\n", sizeStr, e.Name()) - } else { + default: fmt.Fprintf(&out, "f %-8s %s\n", "?", e.Name()) } } |
