Selaa lähdekoodia

cmd/protoc-gen-go: always register file descriptor

Always generate the init func containing the proto.RegisterFile call.
This call used to be in a different init func which was unconditionally
generated. Consolidating the init funcs means that we need to always
generate the single remaining func.

Change-Id: Icbf7d14d018d693dab2824f114c57e4e36384568
Reviewed-on: https://go-review.googlesource.com/c/156197
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Damien Neil 7 vuotta sitten
vanhempi
commit
0dbce8360e
1 muutettua tiedostoa jossa 0 lisäystä ja 4 poistoa
  1. 0 4
      cmd/protoc-gen-go/internal_gengo/main.go

+ 0 - 4
cmd/protoc-gen-go/internal_gengo/main.go

@@ -757,10 +757,6 @@ func extensionVar(f *protogen.File, extension *protogen.Extension) protogen.GoId
 // genInitFunction generates an init function that registers the types in the
 // generated file with the proto package.
 func genInitFunction(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo) {
-	if len(f.allEnums)+len(f.allMessages)+len(f.allExtensions) == 0 {
-		return
-	}
-
 	g.P("func init() {")
 	g.P(f.protoPackage().Ident("RegisterFile"), "(", strconv.Quote(f.Desc.Path()), ", ", f.descriptorVar, ")")
 	for _, enum := range f.allEnums {