Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhuangsirui/binpacker
A binary stream packer and unpacker
https://github.com/zhuangsirui/binpacker
packer unpacker
Last synced: about 2 months ago
JSON representation
A binary stream packer and unpacker
- Host: GitHub
- URL: https://github.com/zhuangsirui/binpacker
- Owner: zhuangsirui
- License: mit
- Created: 2016-02-02T10:06:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-10-08T04:16:12.000Z (over 2 years ago)
- Last Synced: 2024-01-30T04:05:34.074Z (5 months ago)
- Topics: packer, unpacker
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 217
- Watchers: 14
- Forks: 36
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go-extra - binpacker - 02-02T10:06:11Z|2021-10-08T04:16:12Z| (Generators / Bit-packing and Compression)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- fucking-awesome-go - :octocat: binpacker - Binary packer and unpacker helps user build custom binary stream. :star: 14 :fork_and_knife: 1 (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go-projects - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Standard CLI)
- awesome-go - binpacker - | - | - | (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go-with-framework - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go-cn - binpacker
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - 二进制打包器和解包器可以帮助用户构建自定义二进制流。 (<span id="数据结构-data-structures">数据结构 Data Structures</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go. - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go-cn - binpacker - 二进制数据封包拆包工具,帮你构建自定义的二进制数据流 (数据结构 / 高级控制台界面)
- awesome-reader - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go-with-stars - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- repo-1316-awesome-go-cn - binpacker
- repo-1211-awesome-go-cn - binpacker
- awesome-Char - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- Go-awesome - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go-cn - binpacker
- awesome-go-cn - binpacker
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- go-awesome-cn-star - binpacker
- awesome-go-zh - binpacker
- awesome-go-handwritten - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - 二進制數據封包拆包工具,幫你構建自定義的二進制數據流 (數據結構 / 高級控制台界面)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go2 - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. - :arrow_down:1 - :star:24 (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures / Advanced Console UIs)
- awesome-go-stars - binpacker(stars: 218) - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go-cn - binpacker
- awesome-go-cn - binpacker
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go - binpacker - Binary packer and unpacker helps user build custom binary stream. (Data Structures and Algorithms / Bit-packing and Compression)
- awesome-go - binpacker - A binary stream packer and unpacker - ★ 98 (Data Structures)
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)
A binary packer and unpacker.# Install
```bash
go get github.com/zhuangsirui/binpacker
```# Examples
## Packer
```go
buffer := new(bytes.Buffer)
packer := binpacker.NewPacker(binary.BigEndian, buffer)
packer.PushByte(0x01)
packer.PushBytes([]byte{0x02, 0x03})
packer.PushUint16(math.MaxUint16)
``````go
// You can push data like this
buffer := new(bytes.Buffer)
packer := binpacker.NewPacker(binary.BigEndian, buffer)
packer.PushByte(0x01).PushBytes([]byte{0x02, 0x03}).PushUint16(math.MaxUint16)
packer.Error() // Make sure error is nil
```## Unpacker
**Example data**
```go
buffer := new(bytes.Buffer)
packer := binpacker.NewPacker(binary.BigEndian, buffer)
unpacker := binpacker.NewUnpacker(binary.BigEndian, buffer)
packer.PushByte(0x01)
packer.PushUint16(math.MaxUint16)
``````go
var val1 byte
var val2 uint16
var err error
val1, err = unpacker.ShiftByte()
val2, err = unpacker.ShiftUint16()
``````go
var val1 byte
var val2 uint16
var err error
unpacker.FetchByte(&val1).FetchUint16(&val2)
unpacker.Error() // Make sure error is nil
```