cmd/protoc-gen-go: always generate support for reflection

Now that binary bloat concerns have been addressed, remove the flag
to control whether to generate support for reflection.

Change-Id: Ia0d11183707572caaf91d2f01dfa77e3aac0a417
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/167140
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go
index 1fbb90f..e11dc15 100644
--- a/cmd/protoc-gen-go/internal_gengo/reflect.go
+++ b/cmd/protoc-gen-go/internal_gengo/reflect.go
@@ -7,21 +7,12 @@
 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 @@
 // 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 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 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 94f735e..d9f3aea 100644
--- a/internal/cmd/generate-protos/main.go
+++ b/internal/cmd/generate-protos/main.go
@@ -196,7 +196,6 @@
 	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)