https://github.com/Xuanwo/serde-go
Serialize and Deserialize Golang data structures efficiently and generically
https://github.com/Xuanwo/serde-go
deserialize marshal serialize unmarshal
Last synced: 28 days ago
JSON representation
Serialize and Deserialize Golang data structures efficiently and generically
- Host: GitHub
- URL: https://github.com/Xuanwo/serde-go
- Owner: Xuanwo
- License: apache-2.0
- Archived: true
- Created: 2020-10-14T07:18:45.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-30T03:43:02.000Z (almost 3 years ago)
- Last Synced: 2024-10-01T10:50:16.771Z (8 months ago)
- Topics: deserialize, marshal, serialize, unmarshal
- Language: Go
- Homepage:
- Size: 83 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# serde-go
serde-go is a golang port from [serde](https://serde.rs), intended to serialize and deserialize Golang data structures efficiently and generically.
## Tags
Supported tags are listed in [tags](./docs/tags.md)
## Quickstart
```go
// 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:
```shell
go run -tags tools github.com/Xuanwo/serde-go/cmd/serde ./...
```Use a deserializer and serializer to deserialize and serialize:
```go
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)
}
```