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 15:38:38 +00:00
parent 09c25b9975
commit d570c87efc
No known key found for this signature in database
GPG key ID: AF404715446AEB41
13 changed files with 44 additions and 32 deletions

View file

@ -2,6 +2,7 @@ package coredeno
import (
"context"
"errors"
"fmt"
"os"
"os/exec"
@ -14,7 +15,7 @@ func (s *Sidecar) Start(ctx context.Context, args ...string) error {
defer s.mu.Unlock()
if s.cmd != nil {
return fmt.Errorf("coredeno: already running")
return errors.New("coredeno: already running")
}
// Ensure socket directory exists with owner-only permissions

View file

@ -1,6 +1,7 @@
package core
import (
"errors"
"fmt"
"sync"
)
@ -27,7 +28,7 @@ func newServiceManager() *serviceManager {
// It also appends to startables/stoppables if the service implements those interfaces.
func (m *serviceManager) registerService(name string, svc any) error {
if name == "" {
return fmt.Errorf("core: service name cannot be empty")
return errors.New("core: service name cannot be empty")
}
m.mu.Lock()
defer m.mu.Unlock()

View file

@ -19,6 +19,7 @@ package main
import (
"encoding/json"
"errors"
"fmt"
"go/ast"
"go/parser"
@ -101,7 +102,7 @@ func findProjectRoot() (string, error) {
}
parent := filepath.Dir(dir)
if parent == dir {
return "", fmt.Errorf("could not find go.mod in any parent directory")
return "", errors.New("could not find go.mod in any parent directory")
}
dir = parent
}

View file

@ -4,6 +4,7 @@ package i18n
import (
"embed"
"encoding/json"
"errors"
"fmt"
"io/fs"
"path"
@ -118,7 +119,7 @@ func NewWithLoader(loader Loader, opts ...Option) (*Service, error) {
// Load all available languages
langs := loader.Languages()
if len(langs) == 0 {
return nil, fmt.Errorf("no languages available from loader")
return nil, errors.New("no languages available from loader")
}
for _, lang := range langs {
@ -223,7 +224,7 @@ func (s *Service) SetLanguage(lang string) error {
}
if len(s.availableLangs) == 0 {
return fmt.Errorf("no languages available")
return errors.New("no languages available")
}
matcher := language.NewMatcher(s.availableLangs)

View file

@ -3,6 +3,7 @@ package manifest
import (
"crypto/ed25519"
"encoding/base64"
"errors"
"fmt"
"gopkg.in/yaml.v3"
@ -29,7 +30,7 @@ func Sign(m *Manifest, priv ed25519.PrivateKey) error {
// Verify checks the ed25519 signature in m.Sign against the public key.
func Verify(m *Manifest, pub ed25519.PublicKey) (bool, error) {
if m.Sign == "" {
return false, fmt.Errorf("manifest.Verify: no signature present")
return false, errors.New("manifest.Verify: no signature present")
}
sig, err := base64.StdEncoding.DecodeString(m.Sign)
if err != nil {

View file

@ -2,7 +2,7 @@ package process
import (
"context"
"fmt"
"errors"
"sync"
"time"
)
@ -104,7 +104,7 @@ func (r *Runner) RunAll(ctx context.Context, specs []RunSpec) (*RunAllResult, er
Name: name,
Spec: remaining[name],
Skipped: true,
Error: fmt.Errorf("circular dependency or missing dependency"),
Error: errors.New("circular dependency or missing dependency"),
})
}
break
@ -136,7 +136,7 @@ func (r *Runner) RunAll(ctx context.Context, specs []RunSpec) (*RunAllResult, er
Name: spec.Name,
Spec: spec,
Skipped: true,
Error: fmt.Errorf("skipped due to dependency failure"),
Error: errors.New("skipped due to dependency failure"),
}
} else {
result = r.runSpec(ctx, spec)

View file

@ -4,6 +4,7 @@
package repos
import (
"errors"
"fmt"
"os"
"path/filepath"
@ -146,7 +147,7 @@ func FindRegistry(m io.Medium) (string, error) {
}
}
return "", fmt.Errorf("repos.yaml not found")
return "", errors.New("repos.yaml not found")
}
// ScanDirectory creates a Registry by scanning a directory for git repos.

View file

@ -1,6 +1,7 @@
package session
import (
"errors"
"fmt"
"os"
"os/exec"
@ -10,7 +11,7 @@ import (
// RenderMP4 generates an MP4 video from session events using VHS (charmbracelet).
func RenderMP4(sess *Session, outputPath string) error {
if _, err := exec.LookPath("vhs"); err != nil {
return fmt.Errorf("vhs not installed (go install github.com/charmbracelet/vhs@latest)")
return errors.New("vhs not installed (go install github.com/charmbracelet/vhs@latest)")
}
tape := generateTape(sess, outputPath)

View file

@ -2,6 +2,7 @@ package webview
import (
"context"
"errors"
"fmt"
"time"
)
@ -191,7 +192,7 @@ func (a HoverAction) Execute(ctx context.Context, wv *Webview) error {
}
if elem.BoundingBox == nil {
return fmt.Errorf("element has no bounding box")
return errors.New("element has no bounding box")
}
x := elem.BoundingBox.X + elem.BoundingBox.Width/2
@ -495,7 +496,7 @@ func (wv *Webview) DragAndDrop(sourceSelector, targetSelector string) error {
return fmt.Errorf("source element not found: %w", err)
}
if source.BoundingBox == nil {
return fmt.Errorf("source element has no bounding box")
return errors.New("source element has no bounding box")
}
target, err := wv.querySelector(ctx, targetSelector)
@ -503,7 +504,7 @@ func (wv *Webview) DragAndDrop(sourceSelector, targetSelector string) error {
return fmt.Errorf("target element not found: %w", err)
}
if target.BoundingBox == nil {
return fmt.Errorf("target element has no bounding box")
return errors.New("target element has no bounding box")
}
// Calculate center points

View file

@ -2,6 +2,7 @@ package webview
import (
"context"
"errors"
"fmt"
"time"
)
@ -42,7 +43,7 @@ func (ah *AngularHelper) waitForAngular(ctx context.Context) error {
return err
}
if !isAngular {
return fmt.Errorf("not an Angular application")
return errors.New("not an Angular application")
}
// Wait for Zone.js stability
@ -278,13 +279,13 @@ func (ah *AngularHelper) GetRouterState() (*AngularRouterState, error) {
}
if result == nil {
return nil, fmt.Errorf("could not get router state")
return nil, errors.New("could not get router state")
}
// Parse result
resultMap, ok := result.(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid router state format")
return nil, errors.New("invalid router state format")
}
state := &AngularRouterState{

View file

@ -3,6 +3,7 @@ package webview
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@ -121,7 +122,7 @@ func NewCDPClient(debugURL string) (*CDPClient, error) {
}
if wsURL == "" {
return nil, fmt.Errorf("no WebSocket URL available")
return nil, errors.New("no WebSocket URL available")
}
// Connect to WebSocket
@ -306,7 +307,7 @@ func (c *CDPClient) NewTab(url string) (*CDPClient, error) {
}
if target.WebSocketDebuggerURL == "" {
return nil, fmt.Errorf("no WebSocket URL for new tab")
return nil, errors.New("no WebSocket URL for new tab")
}
// Connect to new tab

View file

@ -24,6 +24,7 @@ package webview
import (
"context"
"encoding/base64"
"errors"
"fmt"
"sync"
"time"
@ -122,7 +123,7 @@ func New(opts ...Option) (*Webview, error) {
if wv.client == nil {
cancel()
return nil, fmt.Errorf("no debug URL provided; use WithDebugURL option")
return nil, errors.New("no debug URL provided; use WithDebugURL option")
}
// Enable console capture
@ -222,7 +223,7 @@ func (wv *Webview) Screenshot() ([]byte, error) {
dataStr, ok := result["data"].(string)
if !ok {
return nil, fmt.Errorf("invalid screenshot data")
return nil, errors.New("invalid screenshot data")
}
data, err := base64.StdEncoding.DecodeString(dataStr)
@ -263,7 +264,7 @@ func (wv *Webview) GetURL() (string, error) {
url, ok := result.(string)
if !ok {
return "", fmt.Errorf("invalid URL result")
return "", errors.New("invalid URL result")
}
return url, nil
@ -281,7 +282,7 @@ func (wv *Webview) GetTitle() (string, error) {
title, ok := result.(string)
if !ok {
return "", fmt.Errorf("invalid title result")
return "", errors.New("invalid title result")
}
return title, nil
@ -306,7 +307,7 @@ func (wv *Webview) GetHTML(selector string) (string, error) {
html, ok := result.(string)
if !ok {
return "", fmt.Errorf("invalid HTML result")
return "", errors.New("invalid HTML result")
}
return html, nil
@ -520,7 +521,7 @@ func (wv *Webview) evaluate(ctx context.Context, script string) (any, error) {
return nil, fmt.Errorf("JavaScript error: %s", description)
}
}
return nil, fmt.Errorf("JavaScript error")
return nil, errors.New("JavaScript error")
}
// Extract result value
@ -541,12 +542,12 @@ func (wv *Webview) querySelector(ctx context.Context, selector string) (*Element
root, ok := docResult["root"].(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid document root")
return nil, errors.New("invalid document root")
}
rootID, ok := root["nodeId"].(float64)
if !ok {
return nil, fmt.Errorf("invalid root node ID")
return nil, errors.New("invalid root node ID")
}
// Query selector
@ -576,12 +577,12 @@ func (wv *Webview) querySelectorAll(ctx context.Context, selector string) ([]*El
root, ok := docResult["root"].(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid document root")
return nil, errors.New("invalid document root")
}
rootID, ok := root["nodeId"].(float64)
if !ok {
return nil, fmt.Errorf("invalid root node ID")
return nil, errors.New("invalid root node ID")
}
// Query selector all
@ -595,7 +596,7 @@ func (wv *Webview) querySelectorAll(ctx context.Context, selector string) ([]*El
nodeIDs, ok := queryResult["nodeIds"].([]any)
if !ok {
return nil, fmt.Errorf("invalid node IDs")
return nil, errors.New("invalid node IDs")
}
elements := make([]*ElementInfo, 0, len(nodeIDs))
@ -622,7 +623,7 @@ func (wv *Webview) getElementInfo(ctx context.Context, nodeID int) (*ElementInfo
node, ok := descResult["node"].(map[string]any)
if !ok {
return nil, fmt.Errorf("invalid node description")
return nil, errors.New("invalid node description")
}
tagName, _ := node["nodeName"].(string)

View file

@ -47,6 +47,7 @@ package ws
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"sync"
@ -220,7 +221,7 @@ func (h *Hub) Broadcast(msg Message) error {
select {
case h.broadcast <- data:
default:
return fmt.Errorf("broadcast channel full")
return errors.New("broadcast channel full")
}
return nil
}