msgpack incompatible with Go 1, try to use json instead.

This commit is contained in:
Andrey Smirnov
2013-12-17 11:04:39 +04:00
parent 6c1b3aef3c
commit 807bcc77f9
+6 -12
View File
@@ -1,9 +1,8 @@
package debian package debian
import ( import (
"bytes" "encoding/json"
debc "github.com/smira/godebiancontrol" debc "github.com/smira/godebiancontrol"
"github.com/ugorji/go/codec"
"strings" "strings"
) )
@@ -62,18 +61,13 @@ func (p *Package) Key() []byte {
return []byte(p.Name + " " + p.Version) return []byte(p.Name + " " + p.Version)
} }
// Encode does msgpack encoding of Package // Encode does serializing of Package
func (p *Package) Encode() []byte { func (p *Package) Encode() []byte {
var buf bytes.Buffer result, _ := json.Marshal(p)
return result
encoder := codec.NewEncoder(&buf, &codec.MsgpackHandle{})
encoder.Encode(p)
return buf.Bytes()
} }
// Decode decodes msgpack representation into Package // Decode unserializes representation into Package
func (p *Package) Decode(input []byte) error { func (p *Package) Decode(input []byte) error {
decoder := codec.NewDecoderBytes(input, &codec.MsgpackHandle{}) return json.Unmarshal(input, p)
return decoder.Decode(p)
} }