internal/cmd/generate-protos: disable detrand

The .pb.go.meta file is checked into the repository as testdata.
The deliberate instability of outputs breaks golden tests within
our own repository. It is reasonable for us to depend on stability
since we control the output.

Change-Id: I1f73027a08a0757732d46610f334d40840cc4cfd
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168001
Reviewed-by: Herbie Ong <herbie@google.com>
This commit is contained in:
Joe Tsai 2019-03-18 16:25:54 -07:00 committed by Joe Tsai
parent f31bf2612e
commit ce07f39688

View File

@ -21,6 +21,7 @@ import (
gengogrpc "github.com/golang/protobuf/v2/cmd/protoc-gen-go-grpc/internal_gengogrpc"
gengo "github.com/golang/protobuf/v2/cmd/protoc-gen-go/internal_gengo"
"github.com/golang/protobuf/v2/internal/detrand"
"github.com/golang/protobuf/v2/protogen"
"github.com/golang/protobuf/v2/reflect/protoreflect"
)
@ -30,6 +31,10 @@ func init() {
// we skip running main and instead act as a protoc plugin.
// This allows the binary to pass itself to protoc.
if plugins := os.Getenv("RUN_AS_PROTOC_PLUGIN"); plugins != "" {
// Disable deliberate output instability for generated files.
// This is reasonable since we fully control the output.
detrand.Disable()
protogen.Run(nil, func(gen *protogen.Plugin) error {
for _, plugin := range strings.Split(plugins, ",") {
for _, file := range gen.Files {