{"id":19856784,"url":"https://github.com/yomorun/y3","last_synced_at":"2025-05-02T02:30:22.924Z","repository":{"id":45963311,"uuid":"393382844","full_name":"yomorun/y3","owner":"yomorun","description":"Golang implementation of Y3 Codec, a fast than real-time TLV based binary codec with low CPU usage","archived":false,"fork":false,"pushed_at":"2025-02-24T03:21:58.000Z","size":29,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-27T11:44:19.248Z","etag":null,"topics":["codec","encoder-decoder","golang","realtime","y3","yomo"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yomorun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-08-06T13:18:23.000Z","updated_at":"2025-02-24T03:19:37.000Z","dependencies_parsed_at":"2025-04-19T01:21:39.260Z","dependency_job_id":"f57dd2b6-22bb-4f72-b47b-356521eff72f","html_url":"https://github.com/yomorun/y3","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yomorun%2Fy3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yomorun%2Fy3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yomorun%2Fy3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yomorun%2Fy3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yomorun","download_url":"https://codeload.github.com/yomorun/y3/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251972400,"owners_count":21673598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codec","encoder-decoder","golang","realtime","y3","yomo"],"created_at":"2024-11-12T14:16:35.107Z","updated_at":"2025-05-02T02:30:22.918Z","avatar_url":"https://github.com/yomorun.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e 📚 VERSION: draft-01\n\u003e ⛳️ STATE: v1.0.0\n\n# Y3\n\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fyomorun%2Fy3.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fyomorun%2Fy3?ref=badge_shield)\n\nY3 is the golang implementation of [Y3 Codec](https://github.com/yomorun/y3-codec), which describe a fast and low CPU binding data encoder/decoder focus on edge computing and streaming processing.\n\n# Advantage\n\n- Super fast encode/decode for streaming data\n- Low CPU consumption when decoding large data\n- Random access\n- Tuned for QUIC protocol\n- Designed for global communication at high frequency\n\n## Y3 Codec Specification\n\nSee [Y3 Codec SPEC](https://github.com/yomorun/y3-codec)\n\n## Test\n\n`make test`\n\n## Use\n\n`go get -u github.com/yomorun/y3`\n\n## Examples\n\n### Encode examples\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\ty3 \"github.com/yomorun/y3\"\n)\n\nfunc main() {\n\t// if we want to repesent `var obj = \u0026foo{ID: -1, bar: \u0026bar{Name: \"C\"}}`\n\t// in Y3-Codec:\n\n\t// 0x81 -\u003e node\n\tvar foo = y3.NewNodePacketEncoder(0x01)\n\n\t// 0x02 -\u003e foo.ID=-11\n\tvar yp1 = y3.NewPrimitivePacketEncoder(0x02)\n\typ1.SetInt32Value(-1)\n\tfoo.AddPrimitivePacket(yp1)\n\n\t// 0x83 -\u003e \u0026bar{}\n\tvar bar = y3.NewNodePacketEncoder(0x03)\n\n\t// 0x04 -\u003e bar.Name=\"C\"\n\tvar yp2 = y3.NewPrimitivePacketEncoder(0x04)\n\typ2.SetStringValue(\"C\")\n\tbar.AddPrimitivePacket(yp2)\n\n\t// -\u003e foo.bar=\u0026bar\n\tfoo.AddNodePacket(bar)\n\n\tfmt.Printf(\"res=%#v\", foo.Encode()) // res=[]byte{0x81, 0x08, 0x02, 0x01, 0x7F, 0x83, 0x03, 0x04, 0x01, 0x43}\n}\n```\n\n### Decode examples 1: decode a primitive packet\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\ty3 \"github.com/yomorun/y3\"\n)\n\nfunc main() {\n\tfmt.Println(\"\u003e\u003e Parsing [0x0A, 0x01, 0x7F], which like Key-Value format = 0x0A: 127\")\n\tbuf := []byte{0x0A, 0x01, 0x7F}\n\tres, _, err := y3.DecodePrimitivePacket(buf)\n\tv1, err := res.ToUInt32()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"Tag Key=[%#X], Value=%v\\n\", res.SeqID(), v1)\n}\n```\n\n### Decode examples 2: decode a node packet\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\ty3 \"github.com/yomorun/y3\"\n)\n\nfunc main() {\n\tfmt.Println(\"\u003e\u003e Parsing [0x84, 0x06, 0x0A, 0x01, 0x7F, 0x0B, 0x01, 0x43] EQUALS JSON= 0x84: { 0x0A: -1, 0x0B: 'C' }\")\n\tbuf := []byte{0x84, 0x06, 0x0A, 0x01, 0x7F, 0x0B, 0x01, 0x43}\n\tres, _, err := y3.DecodeNodePacket(buf)\n\tv1 := res.PrimitivePackets[0]\n\n\tp1, err := v1.ToInt32()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"Tag Key=[%#X.%#X], Value=%v\\n\", res.SeqID(), v1.SeqID(), p1)\n\n\tv2 := res.PrimitivePackets[1]\n\n\tp2, err := v2.ToUTF8String()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"Tag Key=[%#X.%#X], Value=%v\\n\", res.SeqID(), v2.SeqID(), p2)\n}\n```\n\nMore examples in `/examples/`\n\n## Types\n\nY3 implements the [YoMo Codec](https://github.com/yomorun/yomo-codec) protocol and supports the following Golang data types:\n\n\u003cdetails\u003e\n  \u003csummary\u003eint32\u003c/summary\u003e\n\t\t\n```golang\n\n````\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003euint32\u003c/summary\u003e\n\n```golang\n````\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eint64\u003c/summary\u003e\n\t\n```golang \n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003euint64\u003c/summary\u003e\n\t\n```golang \n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003efloat32\u003c/summary\u003e\n\t\n```golang\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003efloat64\u003c/summary\u003e\n\t\n```golang\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003ebool\u003c/summary\u003e\n\t\n```golang \n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003estring\u003c/summary\u003e\n  \n```golang\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003ebytes\u003c/summary\u003e\n\t\n```golang\nbuf := []byte(\"yomo\")\np := NewPrimitivePacketEncoder(0x02)\np.SetBytesValue(buf)\nres := p.Encode()\n// res -\u003e { 0x02, 0x04, 0x79, 0x6F, 0x6D, 0x6F }\n```\n\n\u003c/details\u003e\n\n## Contributors\n\n[//]: contributor-faces\n\n\u003ca href=\"https://github.com/figroc\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/2026460?v=3\" title=\"figroc\" width=\"60\" height=\"60\"\u003e\u003c/a\u003e\n\n[//]: contributor-faces\n\n## License\n\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fyomorun%2Fy3.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fyomorun%2Fy3?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyomorun%2Fy3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyomorun%2Fy3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyomorun%2Fy3/lists"}