Skip to content

Commit

Permalink
More corrections
Browse files Browse the repository at this point in the history
Signed-off-by: Yogesh Deshpande <[email protected]>
  • Loading branch information
yogeshbdeshpande committed Sep 18, 2023
1 parent 9110ab6 commit a1366db
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions corim/entity_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,45 @@ type EntityExtension struct {
Param2 byte `cbor:"1,keyasint,omitempty" json:"param2,omitempty"`
}

func (e *EntityExtension) FromCBOR(data []byte) error {
type ProfileXEntity struct {
Entity
Extension EntityExtension `cbor:"8,keyasint" json:"extension"`
}

if err := dm.Unmarshal(data, e); err != nil {
return fmt.Errorf("Failed to unMarshal extension")
}
return nil
func NewProfileXEntity() *ProfileXEntity {
return &ProfileXEntity{}
}

func (e *EntityExtension) ToCBOR() ([]byte, error) {
data, err := em.Marshal(e)
if err != nil {
return nil, fmt.Errorf("unable to CBOR Marshal extension")
func (e *ProfileXEntity) SetEntityExtension(p1 string, p2 byte) {

e.Extension.Param1 = p1
e.Extension.Param2 = p2
}

func (o *ProfileXEntity) FromCBOR(data []byte) error {

Check failure on line 31 in corim/entity_extension.go

View workflow job for this annotation

GitHub Actions / Lint

receiver name o should be consistent with previous receiver name e for ProfileXEntity (golint)
if err := o.Valid(); err != nil {
return fmt.Errorf("invalid Profile XEntity %w", err)
}
fmt.Printf("ToCBOR a success")
return data, nil
return dm.Unmarshal(data, o)
}

func (e *EntityExtension) ExtensionToJSON() ([]byte, error) {
data, err := json.Marshal(e)
if err != nil {
return nil, fmt.Errorf("unable to JSON Marshal extension")
func (o *ProfileXEntity) ToCBOR() ([]byte, error) {

Check failure on line 38 in corim/entity_extension.go

View workflow job for this annotation

GitHub Actions / Lint

receiver name o should be consistent with previous receiver name e for ProfileXEntity (golint)
if err := o.Valid(); err != nil {
return nil, fmt.Errorf("invalid Profile XEntity %w", err)
}
return data, nil
return em.Marshal(o)
}

func (e *EntityExtension) ExtensionFromJSON(data []byte) (interface{}, error) {
func (o *ProfileXEntity) FromJSON(data []byte) error {

Check failure on line 45 in corim/entity_extension.go

View workflow job for this annotation

GitHub Actions / Lint

receiver name o should be consistent with previous receiver name e for ProfileXEntity (golint)
if err := o.Valid(); err != nil {
return err
}
return json.Unmarshal(data, o)
}

if err := json.Unmarshal(data, e); err != nil {
return nil, fmt.Errorf("Failed to JSON UnMarshal extension")
func (o *ProfileXEntity) ToJSON() ([]byte, error) {

Check failure on line 52 in corim/entity_extension.go

View workflow job for this annotation

GitHub Actions / Lint

receiver name o should be consistent with previous receiver name e for ProfileXEntity (golint)
if err := o.Valid(); err != nil {
return nil, err
}
return e, nil
return json.Marshal(o)
}

0 comments on commit a1366db

Please sign in to comment.