# panic: runtime error: invalid memory address or nil pointer dereference in proto.Unmarshal

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

## Root Cause

proto.Unmarshal was called with a nil message pointer, or a generated message's internal fields were not initialized (e.g., using a zero-value struct literal instead of a constructor).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| google.golang.org/protobuf v1.26+ | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   msg := &pb.User{}
if err := proto.Unmarshal(data, msg); err != nil { return err }
   ```
2. **** (90% success)
   ```
   msg := pb.NewUser() // or &pb.User{} then reset
if err := proto.Unmarshal(data, msg); err != nil { return err }
   ```

## Dead Ends

- **** — Swallowing the panic leaves the message nil; subsequent field access panics again and corrupts control flow. (85% fail)
- **** — proto.Unmarshal requires a proto.Message (pointer receiver); passing a value fails to compile or operates on a copy. (80% fail)
