go build_error ai_generated true

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

ID: go/grpc-protobuf-version-mismatch

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-04-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.4 active — — —

Root Cause

The same .proto file is compiled into multiple packages, causing double registration at init time.

generic

中文

同一个 .proto 文件被编译进多个包,导致 init 时重复注册。

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 80% fail

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

  2. 60% fail

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