# panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV] (in goroutine N)

- **ID:** `go/nil-pointer-deref-goroutine`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A goroutine dereferences a nil pointer, commonly a struct field or interface left uninitialized before the goroutine starts.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.21 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Initialize all pointers before spawning the goroutine and prefer value receivers:

cfg := &Config{}
go worker(cfg) // cfg is non-nil
   ```
2. **** (92% success)
   ```
   Add nil guards at goroutine entry and return early with an error:

if s == nil {
    return errors.New("nil service")
}
   ```

## Dead Ends

- **** — The nil deref indicates a logic bug; swallowing it leaves the goroutine's work incomplete and can corrupt state. (80% fail)
- **** — Hides diagnostics; the crash still terminates the program. (95% fail)
