# error: json: cannot unmarshal null into Go value of type main.User

- **ID:** `go/json-unmarshal-null-into-struct`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

JSON 数据中的 null 值被尝试反序列化为结构体，但结构体不支持 null。

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   type User struct { Name *string `json:"name"` }
   ```
2. **** (85% success)
   ```
   var raw json.RawMessage
if err := json.Unmarshal(data, &raw); err != nil { log.Fatal(err) }
   ```

## Dead Ends

- **** — 如果该字段是必需的，会导致数据不完整。 (60% fail)
- **** — 指针可以接受 null，但需要额外处理空值。 (40% fail)
