diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go index 1fbb90fb..e11dc15d 100644 --- a/cmd/protoc-gen-go/internal_gengo/reflect.go +++ b/cmd/protoc-gen-go/internal_gengo/reflect.go @@ -7,21 +7,12 @@ package internal_gengo import ( "fmt" "math" - "os" "strings" "github.com/golang/protobuf/v2/protogen" "github.com/golang/protobuf/v2/reflect/protoreflect" ) -// TODO: Remove this flag. -// Remember to remove the copy in internal/protogen/goldentest. -var enableReflectFlag = os.Getenv("PROTOC_GEN_GO_ENABLE_REFLECT") != "" - -func enableReflection(f *protogen.File) bool { - return enableReflectFlag || isDescriptor(f) -} - // TODO: Remove special-casing for descriptor proto. func isDescriptor(f *protogen.File) bool { return f.Desc.Path() == "google/protobuf/descriptor.proto" && f.Desc.Package() == "google.protobuf" @@ -42,10 +33,6 @@ const ( // TODO: Add support for proto options. func genReflectFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo) { - if !enableReflection(f.File) { - return - } - // Emit a static check that enforces a minimum version of the proto package. // TODO: This should appear higher up in the Go source file. g.P("const _ = ", protoimplPackage.Ident("EnforceVersion"), "(", protoimplPackage.Ident("Version"), " - ", minimumVersion, ")") @@ -224,10 +211,6 @@ func genReflectFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f } func genReflectEnum(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, enum *protogen.Enum) { - if !enableReflection(f.File) { - return - } - idx := f.allEnumsByPtr[enum] typesVar := enumTypesVarName(f) g.P("func (e ", enum.GoIdent, ") Type() ", protoreflectPackage.Ident("EnumType"), " {") @@ -239,10 +222,6 @@ func genReflectEnum(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo } func genReflectMessage(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, message *protogen.Message) { - if !enableReflection(f.File) { - return - } - idx := f.allMessagesByPtr[message] typesVar := messageTypesVarName(f) g.P("func (m *", message.GoIdent, ") ProtoReflect() ", protoreflectPackage.Ident("Message"), " {") diff --git a/internal/cmd/generate-protos/main.go b/internal/cmd/generate-protos/main.go index 94f735e3..d9f3aeaa 100644 --- a/internal/cmd/generate-protos/main.go +++ b/internal/cmd/generate-protos/main.go @@ -196,7 +196,6 @@ func protoc(plugins string, args ...string) { cmd := exec.Command("protoc", "--plugin=protoc-gen-go="+os.Args[0]) cmd.Args = append(cmd.Args, args...) cmd.Env = append(os.Environ(), "RUN_AS_PROTOC_PLUGIN="+plugins) - cmd.Env = append(cmd.Env, "PROTOC_GEN_GO_ENABLE_REFLECT=1") out, err := cmd.CombinedOutput() if err != nil { fmt.Printf("executing: %v\n%s\n", strings.Join(cmd.Args, " "), out)