chore: fmt.Errorf(static) → errors.New

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude 2026-02-24 16:25:14 +00:00
parent 178e49b174
commit c2a57f2227
No known key found for this signature in database
GPG key ID: AF404715446AEB41
7 changed files with 16 additions and 11 deletions

View file

@ -2,6 +2,7 @@
package doctor
import (
"errors"
"fmt"
"forge.lthn.ai/core/cli/pkg/cli"
@ -98,7 +99,7 @@ func runDoctor(verbose bool) error {
cli.Error(i18n.T("cmd.doctor.issues", map[string]any{"Count": failed}))
fmt.Printf("\n%s\n", i18n.T("cmd.doctor.install_missing"))
printInstallInstructions()
return fmt.Errorf("%s", i18n.T("cmd.doctor.issues_error", map[string]any{"Count": failed}))
return errors.New(i18n.T("cmd.doctor.issues_error", map[string]any{"Count": failed}))
}
cli.Success(i18n.T("cmd.doctor.ready"))

View file

@ -2,7 +2,7 @@ package module
import (
"context"
"fmt"
"errors"
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go/pkg/i18n"
@ -21,7 +21,7 @@ func addInstallCommand(parent *cli.Command) {
i18n.T("Install a module by cloning its Git repository, verifying the manifest signature, and registering it.\n\nThe --repo flag is required and specifies the Git URL to clone from."),
func(cmd *cli.Command, args []string) error {
if installRepo == "" {
return fmt.Errorf("--repo flag is required")
return errors.New("--repo flag is required")
}
return runInstall(args[0], installRepo, installSignKey)
},

View file

@ -2,6 +2,7 @@ package module
import (
"context"
"errors"
"fmt"
"forge.lthn.ai/core/cli/pkg/cli"
@ -20,7 +21,7 @@ func addUpdateCommand(parent *cli.Command) {
return runUpdateAll()
}
if len(args) == 0 {
return fmt.Errorf("module code required (or use --all)")
return errors.New("module code required (or use --all)")
}
return runUpdate(args[0])
},

View file

@ -2,6 +2,7 @@ package plugin
import (
"context"
"errors"
"fmt"
"forge.lthn.ai/core/cli/pkg/cli"
@ -22,7 +23,7 @@ func addUpdateCommand(parent *cli.Command) {
return runUpdateAll()
}
if len(args) == 0 {
return fmt.Errorf("plugin name required (or use --all)")
return errors.New("plugin name required (or use --all)")
}
return runUpdate(args[0])
},

View file

@ -3,6 +3,7 @@ package cli
import (
"context"
"errors"
"fmt"
"net"
"net/http"
@ -309,7 +310,7 @@ func (d *Daemon) Start() error {
defer d.mu.Unlock()
if d.running {
return fmt.Errorf("daemon already running")
return errors.New("daemon already running")
}
// Acquire PID file
@ -339,7 +340,7 @@ func (d *Daemon) Run(ctx context.Context) error {
d.mu.Lock()
if !d.running {
d.mu.Unlock()
return fmt.Errorf("daemon not started - call Start() first")
return errors.New("daemon not started - call Start() first")
}
d.mu.Unlock()

View file

@ -2,6 +2,7 @@ package cli
import (
"bufio"
"errors"
"fmt"
"os"
"strconv"
@ -45,7 +46,7 @@ func Select(label string, options []string) (string, error) {
n, err := strconv.Atoi(strings.TrimSpace(input))
if err != nil || n < 1 || n > len(options) {
return "", fmt.Errorf("invalid selection")
return "", errors.New("invalid selection")
}
return options[n-1], nil
}

View file

@ -3,6 +3,7 @@ package cli
import (
"bufio"
"context"
"errors"
"fmt"
"os"
"os/exec"
@ -474,7 +475,6 @@ func parseMultiSelection(input string, maxItems int) ([]int, error) {
return result, nil
}
// ChooseMultiAction prompts for multiple selections using grammar composition.
//
// files := ChooseMultiAction("select", "files", files)
@ -495,14 +495,14 @@ func GitClone(ctx context.Context, org, repo, path string) error {
}
errStr := strings.TrimSpace(string(output))
if strings.Contains(errStr, "already exists") {
return fmt.Errorf("%s", errStr)
return errors.New(errStr)
}
}
// Fall back to SSH clone
cmd := exec.CommandContext(ctx, "git", "clone", fmt.Sprintf("git@github.com:%s/%s.git", org, repo), path)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("%s", strings.TrimSpace(string(output)))
return errors.New(strings.TrimSpace(string(output)))
}
return nil
}