Git Product home page Git Product logo

Comments (4)

zancarius avatar zancarius commented on July 24, 2024

I'd imagine you've probably already figured this out at this point some 5 days later. In case you haven't, I'll give it a shot since this remains unanswered, and I'm in the area.

What I was able to divine from the documentation is most simplistically put as thus (for encoding), as an example:

type SomeData struct {
    /* Fill in the blanks. */
}
data := SomeData{}
buf := &bytes.Buffer{}
encoder := codec.NewEncoder(buf, &codec.MsgpackHandle{})
err := encoder.Encode(&data)

This will write the serialized version of data into buf, or at least should (off the top of my head). There's probably a mistake here or there, but that should get you started in the right direction. Decoding should be fairly similar.

I actually really like ugorji's API, because it works somewhat analogous to the standard library's JSON serializers, only better. You can use it with io.Reader/Writer much more cleanly and it's fairly easy to shoehorn into a REST API or similar if you want to cut down on network traffic overhead a bit more than using, say, JSON. And it's pretty dang fast.

I think the only problem with the documentation is that it demonstrates how to use all the codecs at once. There's nothing wrong with doing that, but if you're new to Golang, it'll probably make your eyes bug out. :) The only advice I can give is to focus on one codec at a time and follow those through the example--it just looks intimidating at first blush.

(The example above doesn't configure the codec, though, so you'll need to appeal to the docs for that.)

from go.

ugorji avatar ugorji commented on July 24, 2024

I will publish a primer early next year.

from go.

giulioungaretti avatar giulioungaretti commented on July 24, 2024

This is great news ! Thank you a lot !
On Wed 24 Dec 2014 at 16:17 ugorji [email protected] wrote:

I will publish a primer early next year.


Reply to this email directly or view it on GitHub
#42 (comment).

from go.

ugorji avatar ugorji commented on July 24, 2024

Primer published: http://ugorji.net/blog/go-codec-primer

from go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.