Giter Site home page Giter Site logo

msgpack-go's Introduction

MessagePack

MessagePack is an efficient binary serialization format. It's like JSON. but fast and small.

This repository manages specification of MessagePack format. See Spec for the specification.

Implementation projects have each own repository. See msgpack.org website to find implementations and their documents.

If you'd like to show your msgpack implementation to the msgpack.org website, please follow the website document.

msgpack-go's People

Contributors

bketelsen avatar dgryski avatar ericliang avatar methane avatar moriyoshi avatar repeatedly avatar skelterjohn avatar ugorji avatar xyproto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msgpack-go's Issues

Deprecate msgpack-go (in favor of go-msgpack)

As msgpack-go is no longer actively maintained mainly because of the original developer being a way too busy to pay attention (kudos to @methane and all the guys having worked on it), I think it's time to start thinking of deprecating msgpack-go and possibly embracing a great alternative, go-msgpack (please supply any if there are more) as a new, official Go implementation of msgpack.

Unpack should return interface{} instead of reflect.Value

I am trying to use this and the RPC library and I think the code requires a major refactor to match standard encoding libraries in Go. I have made changes on the ngmoco fork but I didn't want to open a pull request until there was some discussion around the matter.

I personally suggest trashing the current interface since this separate project is fairly new. It only took me a few hours to switch the code to something that is far more usable.

pack float data wrong

I think that the method of using pack uint data method to pack float data is wrong, because the head sign of packing float is different from the head sign of packing uint, so I modify code:

// Packs a given value and writes it into the specified writer.
func PackFloat32(writer io.Writer, value float32) (n int, err error) {
valueToUint32 := _(_uint32)(unsafe.Pointer(&value))
return writer.Write([]byte{0xca, byte(valueToUint32 >> 24), byte(valueToUint32 >> 16), byte(valueToUint32 >> 8), byte(valueToUint32)})
}

// Packs a given value and writes it into the specified writer.
func PackFloat64(writer io.Writer, value float64) (n int, err error) {
valueToUint64 := _(_uint64)(unsafe.Pointer(&value))
return writer.Write([]byte{0xcb, byte(valueToUint64 >> 56), byte(valueToUint64 >> 48), byte(valueToUint64 >> 40), byte(valueToUint64 >> 32), byte(valueToUint64 >> 24), byte(valueToUint64 >> 16), byte(valueToUint64 >> 8), byte(valueToUint64)})
}

floats need special handling when unpacked

Packing a float value does not necessarily pack it as a float in the underlying protocol you try to optimize for space. This is not a bug, but it makes for very cumbersome code when unpacking floats, because a float can be encoded either a UInt of some length, or an Int of some length.

Unless I'm missing something (I'm pretty new to Go), you have to decode it as such:

switch value.Kind() {
        case reflect.Uint, reflect.Uint64, reflect.Uint32, reflect.Uint16, reflect.Uint8:
            ival := value.Uint()
            fval = *(*float32)(unsafe.Pointer(&ival))
        case reflect.Int, reflect.Int64, reflect.Int32, reflect.Int16, reflect.Int8:
            ival := value.Int()
            fval = *(*float32)(unsafe.Pointer(&ival))
}

Shouldn't this be handled automatically with something like UnpackFloat32/64() ?

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.