# panic: runtime error: invalid memory address or nil pointer dereference

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

## Root Cause

A goroutine dereferenced a nil pointer, often because a struct or channel field was not initialized before the goroutine started, or a nil channel was used in select.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0+ | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   s := &Service{ch: make(chan int, 1)}
go s.run()
   ```
2. **** (85% success)
   ```
   if s == nil || s.ch == nil {
	return
}
// safe to use s.ch
   ```

## Dead Ends

- **** — The nil dereference indicates a real bug; recovering leaves the program in an inconsistent state and the nil access may recur. (75% fail)
- **** — Race conditions and ordering issues mean the pointer may still be nil when accessed; proper initialization must happen before goroutine launch. (70% fail)
