go
build_error
ai_generated
true
protoc-gen-go: error: duplicate symbol "pb.User" in file "user.proto" and "user_v2.proto"
ID: go/proto-duplicate-symbol
80%Fix Rate
87%Confidence
0Evidence
2024-08-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| protoc-gen-go 1.31+ | active | — | — | — |
Root Cause
Two .proto files declare the same fully-qualified message name (same package + message) and are compiled together, causing a symbol collision in generated Go code.
generic中文
两个 .proto 文件声明了相同的完全限定消息名(相同 package + message)并被一起编译,导致生成的 Go 代码中符号冲突。
Workarounds
-
95% success
Give each file a distinct proto package: // user.proto package pb.v1; // user_v2.proto package pb.v2;
-
85% success
Use buf to detect and lint duplicate symbols across the workspace: buf lint buf breaking --against '.git#branch=main'
Dead Ends
Common approaches that don't work:
-
90% fail
The collision is on the protobuf fully-qualified name, not the Go package; protoc still errors.
-
85% fail
At link time the generated Go files still declare identical Go types and the Go build fails.