# panic：proto：消息 pb.Order 中的字段编号 3 已被 "id" 使用

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

## 根因

同一个 proto 消息中的两个字段被分配了相同的字段编号。这是 proto 模式错误，在初始化时被生成的代码捕获。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| google.golang.org/protobuf 1.31+ | active | — | — |

## 解决方案

1. **** (97% 成功率)
   ```
   Assign unique field numbers in the .proto file and regenerate:
message Order {
  int64 id = 1;
  string sku = 2;
  int32 qty = 3;  // not another 3
}
// then: protoc --go_out=. order.proto
   ```
2. **** (92% 成功率)
   ```
   Run buf lint in CI to catch duplicate field numbers before build:
buf lint && buf breaking --against '.git#branch=main'
   ```

## 无效尝试

- **** — The panic is triggered by the proto field numbers in the generated descriptors, not by Go field names; renaming Go fields does not change the descriptor. (90% 失败率)
- **** — The panic occurs during package init before main runs; recover cannot intercept init-time panics. (95% 失败率)
