Browse Source

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>
Joe Tsai 7 years ago
parent
commit
ce07f39688
1 changed files with 5 additions and 0 deletions
  1. 5 0
      internal/cmd/generate-protos/main.go

+ 5 - 0
internal/cmd/generate-protos/main.go

@@ -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 {