binary

package
v0.0.0-...-f8c0f81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2011 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package binary implements translation between unsigned integer values and byte sequences and the reading and writing of fixed-size values.

Index

Constants

This section is empty.

Variables

View Source
var BigEndian bigEndian

BigEndian is the big-endian implementation of ByteOrder.

View Source
var LittleEndian littleEndian

LittleEndian is the little-endian implementation of ByteOrder.

Functions

func Read

func Read(r io.Reader, order ByteOrder, data interface{}) os.Error

Read reads structured binary data from r into data. Data must be a pointer to a fixed-size value or a slice of fixed-size values. A fixed-size value is either a fixed-size arithmetic type (int8, uint8, int16, float32, complex64, ...) or an array or struct containing only fixed-size values. Bytes read from r are decoded using the specified byte order and written to successive fields of the data.

func TotalSize

func TotalSize(v reflect.Value) int

func Write

func Write(w io.Writer, order ByteOrder, data interface{}) os.Error

Write writes the binary representation of data into w. Data must be a fixed-size value or a pointer to a fixed-size value. A fixed-size value is either a fixed-size arithmetic type (int8, uint8, int16, float32, complex64, ...) or an array or struct containing only fixed-size values. Bytes written to w are encoded using the specified byte order and read from successive fields of the data.

Types

type ByteOrder

type ByteOrder interface {
	Uint16(b []byte) uint16
	Uint32(b []byte) uint32
	Uint64(b []byte) uint64
	PutUint16([]byte, uint16)
	PutUint32([]byte, uint32)
	PutUint64([]byte, uint64)
	String() string
}

A ByteOrder specifies how to convert byte sequences into 16-, 32-, or 64-bit unsigned integers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL