Skip to content
This repository has been 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

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)
}

About

Serialize and Deserialize Golang data structures efficiently and generically

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project