Starting and stopping things
summary
Goroutines are GC roots so they hold memory until they exit and cannot be forcibly stopped by another goroutine; shutdown is cooperative and must be requested and observed. Demonstrations show a worker loop racing between a closed stop channel and 50 queued jobs, and an HTTP server that spawns detached logging goroutines which pin requests and blow memory. Solution: a group type with Add(ctx -> error) and Wait, using context, SIGTERM-aware parent context, and panic-to-error capture to trigger orderly shutdowns; this groups services so one error or signal cleanly stops the rest.
AI-written summary · about
