From 5ae35bfee15e2996609bc0473101dc130bb41c4a Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Mon, 9 Jan 2023 18:58:40 +0800 Subject: [PATCH] fix Pb2String --- pkg/utils/utils.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 8d144c7e8..8669e80f7 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -137,12 +137,17 @@ func RemoveRepeatedStringInList(slc []string) []string { } func Pb2String(pb proto.Message) (string, error) { - marshaler := jsonpb.Marshaler{ - OrigName: true, - EnumsAsInts: false, - EmitDefaults: false, + //marshaler := jsonpb.Marshaler{ + // OrigName: true, + // EnumsAsInts: false, + // EmitDefaults: false, + //} + //return marshaler.MarshalToString(pb) + bytes, err := proto.Marshal(pb) + if err != nil { + return "", err } - return marshaler.MarshalToString(pb) + return string(bytes), nil } func String2Pb(s string, pb proto.Message) error {