Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

A simple library for marshalling / unmarshalling objects in golang

License

Notifications You must be signed in to change notification settings

opennetsys/c3-utils-go-marshaller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Go Marshaller

A simple library for marshalling / unmarshalling objects to/from byte arrays in go

Example

import (
  ...
  reqmarshaller "github.com/c3systems/c3-utils-go-marshaller/http/req"
  ...
)

func foo(r *http.Request) error {
  tr, err := reqmarshal.TransformRequest(r)
  if err != nil {
    return err
  }

  b, err := tr.Marshal()
  if err != nil {
    return err
   }

   // do something with the bytes array, b
   // ...

}

func bar(b []byte) error {
  tr := new(reqmarshal.TransformedRequest)
  if err := tr.Unmarshal(b); err != nil {
    return err
   }

   r, err := reqmarshal.UntransformRequest(tr)
   if err != nil {
    return err
   }

   // do something with the request, r
   // ...
}

About

A simple library for marshalling / unmarshalling objects in golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages