single marshaller

This commit is contained in:
livio-a 2020-03-30 16:53:29 +02:00 committed by GitHub
parent 8ced7fb04c
commit c564f47b92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,10 @@ import (
"github.com/caos/logging"
)
var (
marshaller = new(jsonpb.Marshaler)
)
func MustToPBStruct(object interface{}) *pb_struct.Struct {
s, err := ToPBStruct(object)
logging.Log("PROTO-7Aa3t").OnError(err).Panic("unable to map object to pb-struct")
@ -38,7 +42,6 @@ func MustFromPBStruct(object interface{}, s *pb_struct.Struct) {
}
func FromPBStruct(object interface{}, s *pb_struct.Struct) error {
marshaller := new(jsonpb.Marshaler)
jsonString, err := marshaller.MarshalToString(s)
if err != nil {
return err