Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
MessagePack encoding package for Go
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
LICENSE
README.md
msgpack.go

README.md

encoding/msgpack

MessagePack encoding package for Go

Usage

Pack/Unpack

packed, _ := msgpack.Marshal([]interface{}{1, nil, "three"})

var unpacked interface{}
msgpack.Unmarshal(packed, &unpacked)

Streaming

enc := msgpack.NewEncoder(os.Stdout)

enc.Encode(true)
enc.Encode(false)
enc.Encode([]int{1, 2, 3})

dec := msgpack.NewDecoder(os.Stdin)

for {
  var data interface{}

  if dec.Decode(&data) != nil {
    break
  }

  fmt.Println(data)
}

Struct

type Person struct {
  Name string `msgpack:"name"`
  Age  uint8  `msgpack:"age"`
}

var unpacked Person
packed, _ := msgpack.Marshal(Person{"hinasssan", 16})
msgpack.Unmarshal(packed, &unpacked)
fmt.Println(unpacked.Name)
Something went wrong with that request. Please try again.