Documentation
¶
Overview ¶
Package cstruct supports the serialization/deserialization of Go structs
Supported Go struct field types are:
bool - stored as 1 Byte value with 0x01 indicating true and 0x00 indicating false int8 uint8 - equivalent to byte int16 uint16 int32 uint32 int64 uint64 [<n>]<type> - a counted array of <type> struct - an embedded struct []byte - a trailing arbitrarily long slice of bytes
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BigEndian = binary.BigEndian
BigEndian byte order (i.e. most signficant byte first) for {|u}int{16|32|64} types
View Source
var LittleEndian = binary.LittleEndian
LittleEndian byte order (i.e. least signficant byte first) for {|u}int{16|32|64} types
Functions ¶
func Pack ¶
Pack is used to serialize the supplied struct (passed by value or reference) in the desired byte order
func Unpack ¶
func Unpack(src []byte, dstObjIF interface{}, byteOrder binary.ByteOrder) (bytesConsumed uint64, err error)
Unpack is used to deserialize into the supplied struct (passed by reference) in the desired byte order
Note that if the supplied struct contains a trailing byte slice, bytesConsumed will equal len(src)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.