# panic: proto: 消息 pb.User 中字段编号 5 重复

- **ID:** `go/protobuf-duplicate-field-number`
- **领域:** go
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

同一消息中的两个字段共享相同的字段编号，protobuf 禁止此行为。通常由手工编辑生成代码或合并冲突的 .proto 定义引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Assign a unique field number to each field in the .proto, then regenerate with protoc --go_out=. --go-grpc_out=. and never hand-edit generated files.
   ```
2. **** (90% 成功率)
   ```
   Use reserved field numbers to prevent reuse: reserved 5; when removing a field, and run buf lint to catch duplicate numbers at build time.
   ```

## 无效尝试

- **** — The duplicate numbering corrupts wire format; removing the check produces silent data corruption instead of a clear failure. (95% 失败率)
- **** — The number, not the name, is what must be unique; the panic persists. (90% 失败率)
