go.unhandled_error_goroutine
Stability
High
Detects errors not handled in goroutines.
Why It Matters
Section titled “Why It Matters”Unhandled errors in goroutines:
- Silent failures - Errors are lost without logging
- Debugging difficulty - No trace of what went wrong
- Inconsistent state - Failed operations go unnoticed
Example
Section titled “Example”// ❌ Before (error silently ignored)go func() { result, err := processData(data) if err != nil { return // Error is lost! } // use result}()// ✅ After (error properly handled)go func() { result, err := processData(data) if err != nil { log.Printf("processData failed: %v", err) errorChan <- err return } resultChan <- result}()// ✅ Alternative (with error group)g, ctx := errgroup.WithContext(ctx)g.Go(func() error { return processData(ctx, data)})if err := g.Wait(); err != nil { log.Printf("goroutine failed: %v", err)}What Unfault Detects
Section titled “What Unfault Detects”- Error returns ignored in goroutines
- Missing error logging in goroutines
- Goroutines swallowing errors silently
Auto-Fix
Section titled “Auto-Fix”Unfault can add error logging or channel-based error propagation patterns.