Categorygithub.com/roman-kachanovsky/go-binary-pack
module
0.0.0-20170214094030-e260e0dc6732
Repository: https://github.com/roman-kachanovsky/go-binary-pack.git
Documentation: pkg.go.dev

# README

Go BinaryPack

Build Status GoDoc

BinaryPack is a simple Golang library which implements some functionality of Python's struct package.

Install

go get github.com/roman-kachanovsky/go-binary-pack/binary-pack

How to use

// Prepare format (slice of strings)
format := []string{"I", "?", "d", "6s"}

// Prepare values to pack
values := []interface{}{4, true, 3.14, "Golang"}

// Create BinaryPack object
bp := new(BinaryPack)

// Pack values to []byte
data, err := bp.Pack(format, values)

// Unpack binary data to []interface{}
unpacked_values, err := bp.UnPack(format, data)

// You can calculate size of expected binary data by format
size, err := bp.CalcSize(format)

# Packages

Package binary_pack performs conversions between some Go values represented as byte slices.