plugins: Fix code generation for a conflicting oneof#639
Open
sigaev wants to merge 1 commit intogogo:masterfrom
Open
plugins: Fix code generation for a conflicting oneof#639sigaev wants to merge 1 commit intogogo:masterfrom
sigaev wants to merge 1 commit intogogo:masterfrom
Conversation
To reproduce the problem that this pull request fixes:
1. Create x.proto with the following contents:
syntax = "proto3";
message M {
oneof b {
bool a = 1;
bool get_b = 2; // Conflicts with "oneof b".
}
}
2. Run the following commands:
go get github.com/gogo/protobuf/protoc-gen-gofast
protoc --gofast_out=. --plugin=$HOME/go/bin/protoc-gen-gofast x.proto
grep M_GetB x.pb.go
3. Output will show that MarshalTo, MarshalToSizedBuffer, Size
all have an incorrectly named receiver, M_GetB. It needs to be
M_GetB_ instead:
// *M_GetB_
type M_GetB_ struct {
func (*M_GetB_) isM_B() {}
if x, ok := m.GetB().(*M_GetB_); ok {
(*M_GetB_)(nil),
func (m *M_GetB) MarshalTo(dAtA []byte) (int, error) {
func (m *M_GetB) MarshalToSizedBuffer(dAtA []byte) (int, error) {
func (m *M_GetB) Size() (n int) {
m.B = &M_GetB{b}
|
Hi @jmarais! Could you help with the PR? It's been an issue for several projects on our side as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To reproduce the problem that this pull request fixes:
x.protowith the following contents:go get github.com/gogo/protobuf/protoc-gen-gofast protoc --gofast_out=. --plugin=$HOME/go/bin/protoc-gen-gofast x.proto grep M_GetB x.pb.goMarshalTo,MarshalToSizedBuffer,Sizeall have an incorrectly named receiver,
M_GetB. It needs to beM_GetB_instead: