Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 723 Bytes

File metadata and controls

33 lines (24 loc) · 723 Bytes

postcard

A Go parser for Postcard binary wire format.

Follows the same design principles as jsony, which allows for fast, type-safe, and reflection-free deserialization.

Installation

go get github.com/orsinium-labs/postcard

Usage

type User struct {
    name string
    age  uint16
}

var user User
parse := postcard.Struct(
    postcard.Str(&user.name),
    postcard.U16(&user.age),
)

reader := bytes.NewReader([]byte("\x07Aragorn\x52"))
err := parse(reader)

fmt.Println(err)       // nil
fmt.Println(user.name) // "Aragorn"
fmt.Println(user.age)  // 82