Skip to content

Commit 1d5d3f9

Browse files
author
Mohd Uzair
authored
Merge pull request #564 from MUzairS15/MUzairS15/encoding
Add `Marshal` function for encoding package.
2 parents 6bec777 + d648931 commit 1d5d3f9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

encoding/encoding.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package encoding
33
import (
44
"encoding/json"
55

6+
"github.com/layer5io/meshkit/utils"
67
"gopkg.in/yaml.v2"
78
)
89

@@ -49,3 +50,15 @@ func unmarshalJSON(data []byte, result interface{}) error {
4950
}
5051
return nil
5152
}
53+
54+
func Marshal(in interface{}) ([]byte, error) {
55+
result, err := json.Marshal(in)
56+
if err != nil {
57+
result, err = yaml.Marshal(in)
58+
if err != nil {
59+
return nil, utils.ErrMarshal(err)
60+
}
61+
}
62+
63+
return result, nil
64+
}

models/meshmodel/registry/registry.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,11 @@ func (rm *RegistryManager) Cleanup() {
8181
func (rm *RegistryManager) RegisterEntity(h connection.Connection, en entity.Entity) (bool, bool, error) {
8282
registrantID, err := h.Create(rm.db)
8383
if err != nil {
84-
fmt.Println("REGISTRANT ERROR ")
8584
return true, false, err
8685
}
8786

8887
entityID, err := en.Create(rm.db, registrantID)
8988
if err != nil {
90-
fmt.Println("COMP ERROR ")
9189
return false, true, err
9290
}
9391
id, _ := uuid.NewV4()

0 commit comments

Comments
 (0)