internal/fieldnum: generate field numbers for the google.protobuf package
Generate field numbers for the well-known types,
so that encoding/jsonpb can benefit from them as well.
This CL fixes internal/cmd/generate-protos, which was silently failing
because the modulePath was not properly initialized. We fix this by
moving it to the start of the init function.
Change-Id: I87637176f29218cffa512b4baa49f39dae924061
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168497
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 b3f7bcf..95e6611 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -17,8 +17,8 @@
"unicode"
"unicode/utf8"
- "github.com/golang/protobuf/v2/internal/descfield"
"github.com/golang/protobuf/v2/internal/encoding/tag"
+ "github.com/golang/protobuf/v2/internal/fieldnum"
"github.com/golang/protobuf/v2/proto"
"github.com/golang/protobuf/v2/protogen"
"github.com/golang/protobuf/v2/reflect/protoreflect"
@@ -115,7 +115,7 @@
g.P()
g.PrintLeadingComments(protogen.Location{
SourceFile: f.Proto.GetName(),
- Path: []int32{descfield.FileDescriptorProto_Package},
+ Path: []int32{fieldnum.FileDescriptorProto_Package},
})
g.P()
g.P("package ", f.GoPackageName)