util

package
v0.0.0-...-3d371da Latest Latest
Warning

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

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

Documentation

Overview

Package util contains low lever helper function for parsing byte buffers

Index

Constants

View Source
const (
	LenByte    = 1
	LenUint16  = 2
	LenUint32  = 4
	LenUint64  = 8
	LenFloat64 = 8
)

convenience consts describing the length of certain C types in bytes

Variables

This section is empty.

Functions

func ReadAll

func ReadAll(r io.Reader, capacity int64) (b []byte, err error)

ReadAll is taken verbatim from ioutil in the standard library and we use it to read the binary count data into a preallocated buffer of the correct size. Using a correctly preallocated buffer is critical especially for large binary data files in the multi GB range to avoid excessive memory use due to uncollected memory

func ReadByte

func ReadByte(r io.Reader) (byte, error)

ReadByte reads a single byte from an io.Reader

func ReadFloat64

func ReadFloat64(r io.Reader) (float64, error)

ReadFloat64 reads a float64 from an io.Reader

func ReadUint16

func ReadUint16(r io.Reader) (uint16, error)

ReadUint16 reads an uint16 from an io.Reader

func ReadUint32

func ReadUint32(r io.Reader) (uint32, error)

ReadUint32 reads an uint32 from an io.Reader

func ReadUint64

func ReadUint64(r io.Reader) (uint64, error)

ReadUint64 reads an uint64 from an io.Reader

Types

type ReadBuf

type ReadBuf []byte

ReadBuf and helper function convert between a byte slice and an underlying integer type NOTE: This code was take almost verbatim from archive/zip/reader from the standard library

func (*ReadBuf) Float64

func (b *ReadBuf) Float64() float64

Float64 converts a Readbuf into a float64

func (*ReadBuf) Uint16

func (b *ReadBuf) Uint16() uint16

Uint16 converts a Readbuf into an uint16

func (*ReadBuf) Uint32

func (b *ReadBuf) Uint32() uint32

Uint32 converts a Readbuf into an uint32

func (*ReadBuf) Uint64

func (b *ReadBuf) Uint64() uint64

Uint64 converts a Readbuf into an uint64

Jump to

Keyboard shortcuts

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