Skip to content

Commit 24f28ae

Browse files
GooglerLMMilewski
authored andcommitted
protoc-gen-go: Add Filename to ExtensionDesc.
This will allow looking up the FileDescriptorProto for the file that defines an extension of a message, for richer introspection.
1 parent 1bdfb32 commit 24f28ae

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

proto/extensions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ type ExtensionDesc struct {
154154
Field int32 // field number
155155
Name string // fully-qualified name of extension, for text formatting
156156
Tag string // protobuf tag style
157+
Filename string // name of the file in which the extension is defined
157158
}
158159

159160
func (ed *ExtensionDesc) repeated() bool {

protoc-gen-go/generator/generator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,6 +2556,7 @@ func (g *Generator) generateExtension(ext *ExtensionDescriptor) {
25562556
g.P("Field: ", field.Number, ",")
25572557
g.P(`Name: "`, extName, `",`)
25582558
g.P("Tag: ", tag, ",")
2559+
g.P(`Filename: "`, g.file.GetName(), `",`)
25592560

25602561
g.Out()
25612562
g.P("}")

0 commit comments

Comments
 (0)