Fix remaining errcheck warnings in daemon.go, daemon_lock.go, delete.go
- daemon.go: fix os.Remove() in stopDaemon (line 602) - daemon_lock.go: fix f.Close() and fmt.Fprintf() calls - delete.go: fix cmd.Usage(), out.Close(), and os.Remove() calls All error returns now properly handled or explicitly ignored. Amp-Thread-ID: https://ampcode.com/threads/T-56b6d9f4-16a4-4c50-b7b9-dde1c3774650 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -599,7 +599,7 @@ func stopDaemon(pidFile string) {
|
||||
fmt.Fprintf(os.Stderr, "Error killing process: %v\n", err)
|
||||
}
|
||||
}
|
||||
os.Remove(pidFile)
|
||||
_ = os.Remove(pidFile)
|
||||
fmt.Println("Daemon killed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func acquireDaemonLock(beadsDir string, global bool) (*DaemonLock, error) {
|
||||
|
||||
// Try to acquire exclusive non-blocking lock
|
||||
if err := flockExclusive(f); err != nil {
|
||||
f.Close()
|
||||
_ = f.Close()
|
||||
if err == ErrDaemonLocked {
|
||||
return nil, ErrDaemonLocked
|
||||
}
|
||||
@@ -51,7 +51,7 @@ func acquireDaemonLock(beadsDir string, global bool) (*DaemonLock, error) {
|
||||
// Write our PID to the lock file for debugging (optional)
|
||||
_ = f.Truncate(0)
|
||||
_, _ = f.Seek(0, 0)
|
||||
fmt.Fprintf(f, "%d\n", os.Getpid())
|
||||
_, _ = fmt.Fprintf(f, "%d\n", os.Getpid())
|
||||
_ = f.Sync()
|
||||
|
||||
// Also write PID file for Windows compatibility (can't read locked files on Windows)
|
||||
@@ -74,7 +74,7 @@ func tryDaemonLock(beadsDir string) (running bool, pid int) {
|
||||
// Fall back to PID file check for backward compatibility
|
||||
return checkPIDFile(beadsDir)
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() { _ = f.Close() }()
|
||||
|
||||
// Try to acquire lock non-blocking
|
||||
if err := flockExclusive(f); err != nil {
|
||||
|
||||
@@ -70,7 +70,7 @@ Force: Delete and orphan dependents
|
||||
|
||||
if len(issueIDs) == 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error: no issue IDs provided\n")
|
||||
cmd.Usage()
|
||||
_ = cmd.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -353,8 +353,8 @@ func removeIssueFromJSONL(issueID string) error {
|
||||
enc := json.NewEncoder(out)
|
||||
for _, iss := range issues {
|
||||
if err := enc.Encode(iss); err != nil {
|
||||
out.Close()
|
||||
os.Remove(temp)
|
||||
_ = out.Close()
|
||||
_ = os.Remove(temp)
|
||||
return fmt.Errorf("failed to write issue: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user