internal/cmd/generate-protos: generate internal descfield package
Generate a list of descriptor fields from the descriptor.proto itself
as an internal package. Use these fields for the internal implementation.
Change-Id: Ib1ab0c5c6deb332ba6c8018ef55136b7e5974944
Reviewed-on: https://go-review.googlesource.com/c/164864
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
index 4748f67..c124467 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -18,6 +18,7 @@
"unicode/utf8"
"github.com/golang/protobuf/proto"
+ "github.com/golang/protobuf/v2/internal/descfield"
"github.com/golang/protobuf/v2/internal/encoding/tag"
"github.com/golang/protobuf/v2/protogen"
"github.com/golang/protobuf/v2/reflect/protoreflect"
@@ -118,10 +119,9 @@
g.P("// source: ", f.Desc.Path())
}
g.P()
- const filePackageField = 2 // FileDescriptorProto.package
g.PrintLeadingComments(protogen.Location{
SourceFile: f.Proto.GetName(),
- Path: []int32{filePackageField},
+ Path: []int32{descfield.FileDescriptorProto_Package},
})
g.P()
g.P("package ", f.GoPackageName)