go build_error ai_generated true

panic:proto:文件 "service.proto" 已注册

panic: proto: file "service.proto" is already registered

ID: go/grpc-protobuf-version-mismatch

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 90% 成功率
    Check go.mod for duplicate dependencies and use replace directives to unify versions.
  2. 50% 成功率
    proto.RegisterFile("custom_service.proto", fileDescriptor)

无效尝试

常见但无效的做法:

  1. 80% 失败

    Regeneration will still produce the same conflict if imports are duplicated.

  2. 60% 失败

    Renaming the package doesn't resolve the file registration conflict.