Created
September 3, 2016 19:25
-
-
Save 178inaba/5d8231103bdeac5e905d251b26b4c71d to your computer and use it in GitHub Desktop.
MessagePack in go.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/ugorji/go/codec" | |
) | |
func main() { | |
material := "onion potato carrot" | |
ladle := &codec.MsgpackHandle{} | |
pot := []byte{} | |
err := codec.NewEncoderBytes(&pot, ladle).Encode(material) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(pot) | |
var curry string | |
err = codec.NewDecoderBytes(pot, ladle).Decode(&curry) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(curry) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment