{"id":13411362,"url":"https://github.com/zhuangsirui/binpacker","last_synced_at":"2025-03-14T17:30:40.343Z","repository":{"id":48706070,"uuid":"50911581","full_name":"zhuangsirui/binpacker","owner":"zhuangsirui","description":"A binary stream packer and unpacker","archived":false,"fork":false,"pushed_at":"2021-10-08T04:16:12.000Z","size":19,"stargazers_count":218,"open_issues_count":1,"forks_count":37,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-07-31T20:45:37.431Z","etag":null,"topics":["packer","unpacker"],"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/zhuangsirui.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}},"created_at":"2016-02-02T10:06:11.000Z","updated_at":"2024-06-25T05:30:01.000Z","dependencies_parsed_at":"2022-09-14T12:41:11.592Z","dependency_job_id":null,"html_url":"https://github.com/zhuangsirui/binpacker","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuangsirui%2Fbinpacker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuangsirui%2Fbinpacker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuangsirui%2Fbinpacker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhuangsirui%2Fbinpacker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhuangsirui","download_url":"https://codeload.github.com/zhuangsirui/binpacker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618596,"owners_count":20320263,"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":["packer","unpacker"],"created_at":"2024-07-30T20:01:13.157Z","updated_at":"2025-03-14T17:30:40.082Z","avatar_url":"https://github.com/zhuangsirui.png","language":"Go","funding_links":[],"categories":["数据结构与算法","Data Structures","Data Structures and Algorithms","数据结构","數據結構","数据结构`go语言实现的数据结构与算法`","Generators","Go","Data Integration Frameworks","Uncategorized","\u003cspan id=\"数据结构-data-structures\"\u003e数据结构 Data Structures\u003c/span\u003e"],"sub_categories":["Bit-packing和压缩","Advanced Console UIs","Standard CLI","Bit-packing and Compression","高级控制台界面","高級控制台界面","标准 CLI","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"# binpacker [![Build Status](https://travis-ci.org/zhuangsirui/binpacker.svg?branch=master)](https://travis-ci.org/zhuangsirui/binpacker) [![GoDoc](https://godoc.org/github.com/zhuangsirui/binpacker?status.svg)](https://godoc.org/github.com/zhuangsirui/binpacker) [![Go Report Card](https://goreportcard.com/badge/github.com/zhuangsirui/binpacker)](https://goreportcard.com/report/github.com/zhuangsirui/binpacker)\nA binary packer and unpacker.\n\n# Install\n\n```bash\ngo get github.com/zhuangsirui/binpacker\n```\n\n# Examples\n\n## Packer\n\n```go\nbuffer := new(bytes.Buffer)\npacker := binpacker.NewPacker(binary.BigEndian, buffer)\npacker.PushByte(0x01)\npacker.PushBytes([]byte{0x02, 0x03})\npacker.PushUint16(math.MaxUint16)\n```\n\n```go\n// You can push data like this\nbuffer := new(bytes.Buffer)\npacker := binpacker.NewPacker(binary.BigEndian, buffer)\npacker.PushByte(0x01).PushBytes([]byte{0x02, 0x03}).PushUint16(math.MaxUint16)\npacker.Error() // Make sure error is nil\n```\n\n## Unpacker\n\n**Example data**\n\n```go\nbuffer := new(bytes.Buffer)\npacker := binpacker.NewPacker(binary.BigEndian, buffer)\nunpacker := binpacker.NewUnpacker(binary.BigEndian, buffer)\npacker.PushByte(0x01)\npacker.PushUint16(math.MaxUint16)\n```\n\n```go\nvar val1 byte\nvar val2 uint16\nvar err error\nval1, err = unpacker.ShiftByte()\nval2, err = unpacker.ShiftUint16()\n```\n\n```go\nvar val1 byte\nvar val2 uint16\nvar err error\nunpacker.FetchByte(\u0026val1).FetchUint16(\u0026val2)\nunpacker.Error() // Make sure error is nil\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhuangsirui%2Fbinpacker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhuangsirui%2Fbinpacker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhuangsirui%2Fbinpacker/lists"}