func (e *JSONPBEncoder) Encode(pb proto.Message) ([]byte, error) {
	var buf bytes.Buffer
	err := e.marshaler.Marshal(&buf, pb)
	return buf.Bytes(), err
}
Encode protobuf struct to bytes.
package codec
import (
	"bytes"
	"encoding/json"
	"github.com/gogo/protobuf/jsonpb"
	"github.com/gogo/protobuf/proto"
	historypb "go.temporal.io/api/history/v1"
)
type (
	JSONPBEncoder struct {
		marshaler   jsonpb.Marshaler
		ubmarshaler jsonpb.Unmarshaler
	}
)
func NewJSONPBEncoder() *JSONPBEncoder {
	return &JSONPBEncoder{
		marshaler:   jsonpb.Marshaler{},
		ubmarshaler: jsonpb.Unmarshaler{},
	}
}
func NewJSONPBIndentEncoder(indent string) *JSONPBEncoder {
	return &JSONPBEncoder{
		marshaler:   jsonpb.Marshaler{Indent: indent},
		ubmarshaler: jsonpb.Unmarshaler{},
	}
}