cmd/protoc-gen-go: only depend on v2 proto package

This CL breaks another dependency of v2 on v1.
A missing feature in v2 is proto.Clone, but we can use a
Marshal/Unmarshal roundtrip to achieve the same effect
as a temporary stop-gap.

Change-Id: I9d0432fd3efe9fc8b34db6c5a1eabbef0c36277c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168217
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
index f204853..7a28ae6 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -17,9 +17,9 @@
 	"unicode"
 	"unicode/utf8"
 
-	"github.com/golang/protobuf/proto"
 	"github.com/golang/protobuf/v2/internal/descfield"
 	"github.com/golang/protobuf/v2/internal/encoding/tag"
+	"github.com/golang/protobuf/v2/proto"
 	"github.com/golang/protobuf/v2/protogen"
 	"github.com/golang/protobuf/v2/reflect/protoreflect"
 
@@ -228,11 +228,21 @@
 }
 
 func genFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo) {
+	// TODO: Replace this with v2 Clone.
+	descProto := new(descriptorpb.FileDescriptorProto)
+	b, err := proto.Marshal(f.Proto)
+	if err != nil {
+		gen.Error(err)
+		return
+	}
+	if err := proto.Unmarshal(b, descProto); err != nil {
+		gen.Error(err)
+		return
+	}
+
 	// Trim the source_code_info from the descriptor.
-	// Marshal and gzip it.
-	descProto := proto.Clone(f.Proto).(*descriptorpb.FileDescriptorProto)
 	descProto.SourceCodeInfo = nil
-	b, err := proto.Marshal(descProto)
+	b, err = proto.MarshalOptions{Deterministic: true}.Marshal(descProto)
 	if err != nil {
 		gen.Error(err)
 		return