fix(lint): resolve all errcheck warnings

Fix ~50 errcheck warnings across the codebase:

- Add explicit `_ =` for intentionally ignored error returns (cleanup,
  best-effort operations, etc.)
- Use `defer func() { _ = ... }()` pattern for defer statements
- Handle tmux SetEnvironment, KillSession, SendKeysRaw returns
- Handle mail router.Send returns
- Handle os.RemoveAll, os.Rename in cleanup paths
- Handle rand.Read returns for ID generation
- Handle fmt.Fprint* returns when writing to io.Writer
- Fix for-select with single case to use for-range
- Handle cobra MarkFlagRequired returns

All tests pass. Code compiles without errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-19 12:09:52 -08:00
parent 3a477f673c
commit 4048cdc373
29 changed files with 115 additions and 125 deletions

View File

@@ -61,7 +61,7 @@ func (d *Daemon) Run() error {
if err := os.WriteFile(d.config.PidFile, []byte(strconv.Itoa(os.Getpid())), 0644); err != nil {
return fmt.Errorf("writing PID file: %w", err)
}
defer os.Remove(d.config.PidFile)
defer func() { _ = os.Remove(d.config.PidFile) }()
// Update state
state := &State{
@@ -312,7 +312,7 @@ func IsRunning(townRoot string) (bool, int, error) {
err = process.Signal(syscall.Signal(0))
if err != nil {
// Process not running, clean up stale PID file
os.Remove(pidFile)
_ = os.Remove(pidFile)
return false, 0, nil
}
@@ -345,12 +345,12 @@ func StopDaemon(townRoot string) error {
// Check if still running
if err := process.Signal(syscall.Signal(0)); err == nil {
// Still running, force kill
process.Signal(syscall.SIGKILL)
_ = process.Signal(syscall.SIGKILL)
}
// Clean up PID file
pidFile := filepath.Join(townRoot, "daemon", "daemon.pid")
os.Remove(pidFile)
_ = os.Remove(pidFile)
return nil
}

View File

@@ -196,7 +196,7 @@ func (d *Daemon) restartSession(sessionName, identity string) error {
}
// Set environment
d.tmux.SetEnvironment(sessionName, "GT_ROLE", identity)
_ = d.tmux.SetEnvironment(sessionName, "GT_ROLE", identity)
// Send startup command
if err := d.tmux.SendKeys(sessionName, startCmd); err != nil {