Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.
/ serde-go Public archive

Serialize and Deserialize Golang data structures efficiently and generically

License

Notifications You must be signed in to change notification settings

Xuanwo/serde-go

Folders and files

NameName
Last commit message
Last commit date
Dec 16, 2020
Dec 21, 2020
Dec 16, 2020
Dec 17, 2020
Dec 21, 2020
Oct 19, 2020
Oct 20, 2020
Oct 20, 2020
Dec 16, 2020
Dec 16, 2020
Dec 21, 2020
Dec 17, 2020
Dec 16, 2020
Dec 17, 2020
Dec 1, 2020
Oct 19, 2020
Jun 30, 2022
Jun 30, 2022
Oct 20, 2020
Dec 14, 2020
Dec 14, 2020

Repository files navigation

serde-go

serde-go is a golang port from serde, intended to serialize and deserialize Golang data structures efficiently and generically.

Tags

Supported tags are listed in tags

Quickstart

// serde: deserialize,serialize
type Example struct {
	vint64   int64
	vmap     map[int]int
	varray   [2]int `serde:"skip"`
	vslice   []int
	vpointer *int
}

Use serde-go to generate deserialize and serialize for it:

go run -tags tools github.com/Xuanwo/serde-go/cmd/serde ./...

Use a deserializer and serializer to deserialize and serialize:

import (
    "log"
    "testing"

    msgpack "github.com/Xuanwo/serde-msgpack-go"
)

func main() {
	ta := Example{
		A: "xxx",
	}
	content, err := msgpack.SerializeToBytes(&ta)
	if err != nil {
		log.Fatalf("msgpack SerializeToBytes: %v", err)
	}

	x := Example{}
	err = msgpack.DeserializeFromBytes(content, &x)
	if err != nil {
        log.Fatalf("msgpack DeserializeFromBytes: %v", err)
	}
	log.Printf("%#+v", x)
}