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/protogen/protogen.go b/protogen/protogen.go
index cf1e809..23bc69a 100644
--- a/protogen/protogen.go
+++ b/protogen/protogen.go
@@ -28,9 +28,10 @@
"strconv"
"strings"
- "github.com/golang/protobuf/proto"
+ "github.com/golang/protobuf/v2/encoding/textpb"
"github.com/golang/protobuf/v2/internal/descfield"
"github.com/golang/protobuf/v2/internal/scalar"
+ "github.com/golang/protobuf/v2/proto"
"github.com/golang/protobuf/v2/reflect/protodesc"
"github.com/golang/protobuf/v2/reflect/protoreflect"
"github.com/golang/protobuf/v2/reflect/protoregistry"
@@ -1109,7 +1110,11 @@
}
}
- return strings.TrimSpace(proto.CompactTextString(info)), nil
+ b, err := textpb.MarshalOptions{Compact: true}.Marshal(info)
+ if err != nil {
+ return "", err
+ }
+ return string(b), nil
}
type pathType int