Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc-gen-go: Don't rely on local package name for mset name hack. #562

Merged
merged 1 commit into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions protoc-gen-go/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2782,10 +2782,15 @@ func (g *Generator) generateExtension(ext *ExtensionDescriptor) {
typeName := ext.TypeName()

// Special case for proto2 message sets: If this extension is extending
// proto2_bridge.MessageSet, and its final name component is "message_set_extension",
// proto2.bridge.MessageSet, and its final name component is "message_set_extension",
// then drop that last component.
//
// TODO: This should be implemented in the text formatter rather than the generator.
// In addition, the situation for when to apply this special case is implemented
// differently in other languages:
// https://github.com/google/protobuf/blob/aff10976/src/google/protobuf/text_format.cc#L1560
mset := false
if extendedType == "*proto2_bridge.MessageSet" && typeName[len(typeName)-1] == "message_set_extension" {
if extDesc.GetOptions().GetMessageSetWireFormat() && typeName[len(typeName)-1] == "message_set_extension" {
typeName = typeName[:len(typeName)-1]
mset = true
}
Expand Down
3 changes: 2 additions & 1 deletion protoc-gen-go/testdata/extension_user/extension_user.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.