repositorypackage
0.0.0-20170319194158-5b770d80ac07
Repository: https://github.com/wesleiramos/pystruct.git
Documentation: pkg.go.dev
# README
pystruct
Pystruct is a module like python struct module
Install package
> go get github.com/WesleiRamos/pystruct
Usage:
Pack
returns byte array
Unpack
returns interface array
NOTICE: Tested only with small values
package main
import "fmt"
import "reflect"
import "github.com/WesleiRamos/pystruct"
func main() {
h := "kk eae man"
b := pystruct.Pack("!hs", len(h), h)
fmt.Printf("%q\n", b) // "\x00\nkk eae man"
u, err := pystruct.Unpack("!h", b[:2])
if err != nil {
panic(err)
}
fmt.Printf("%s\n", b[2:2+reflect.ValueOf(u[0]).Int()]) // kk eae man
}