go
build_error
ai_generated
true
panic:proto:文件 "service.proto" 已注册
panic: proto: file "service.proto" is already registered
ID: go/grpc-protobuf-version-mismatch
80%修复率
90%置信度
0证据数
2024-04-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.4 | active | — | — | — |
根因分析
同一个 .proto 文件被编译进多个包,导致 init 时重复注册。
English
The same .proto file is compiled into multiple packages, causing double registration at init time.
解决方案
-
90% 成功率
Check go.mod for duplicate dependencies and use replace directives to unify versions.
-
50% 成功率
proto.RegisterFile("custom_service.proto", fileDescriptor)
无效尝试
常见但无效的做法:
-
80% 失败
Regeneration will still produce the same conflict if imports are duplicated.
-
60% 失败
Renaming the package doesn't resolve the file registration conflict.