util

package
v0.0.0-...-b9de21a Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: LGPL-3.0 Imports: 3 Imported by: 38

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLength = errors.New("invalid length")
)

util errors

Functions

func BytesToUint16

func BytesToUint16(v []byte) uint16

BytesToUint16 returns a uint16 number of the byte array

func BytesToUint32

func BytesToUint32(v []byte) uint32

BytesToUint32 returns a uint32 number of the byte array

func BytesToUint64

func BytesToUint64(v []byte) uint64

BytesToUint64 returns a uint64 number of the byte array

func FillBytes

func FillBytes(r io.Reader, bs []byte) (int64, error)

FillBytes reads bytes from the reader until the given bytes array is filled

func ReadBool

func ReadBool(r io.Reader) (bool, int64, error)

ReadBool reads a bool using a uint8 from the reader

func ReadBytes

func ReadBytes(r io.Reader) ([]byte, int64, error)

ReadBytes reads a byte array from the reader

func ReadString

func ReadString(r io.Reader) (string, int64, error)

ReadString reads a string array from the reader

func ReadUint16

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

ReadUint16 reads a uint16 number from the reader

func ReadUint32

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

ReadUint32 reads a uint32 number from the reader

func ReadUint64

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

ReadUint64 reads a uint64 number from the reader

func ReadUint8

func ReadUint8(r io.Reader) (uint8, int64, error)

ReadUint8 reads a uint8 number from the reader

func Uint16ToBytes

func Uint16ToBytes(v uint16) []byte

Uint16ToBytes returns a byte array of the uint16 number

func Uint32ToBytes

func Uint32ToBytes(v uint32) []byte

Uint32ToBytes returns a byte array of the uint32 number

func Uint48ToBytes

func Uint48ToBytes(a uint32, b uint16) []byte

Uint48ToBytes returns a byte array of the uint32 number and the uint16 number

func Uint64ToBytes

func Uint64ToBytes(v uint64) []byte

Uint64ToBytes returns a byte array of the uint64 number

func WriteBool

func WriteBool(w io.Writer, b bool) (int64, error)

WriteBool writes the bool using a uint8 to the writer

func WriteBytes

func WriteBytes(w io.Writer, bs []byte) (int64, error)

WriteBytes writes the byte array bytes with the var-length-bytes to the writer

func WriteString

func WriteString(w io.Writer, str string) (int64, error)

WriteString writes the string with the var-length-byte to the writer

func WriteUint16

func WriteUint16(w io.Writer, num uint16) (int64, error)

WriteUint16 writes the uint16 number to the writer

func WriteUint32

func WriteUint32(w io.Writer, num uint32) (int64, error)

WriteUint32 writes the uint32 number to the writer

func WriteUint64

func WriteUint64(w io.Writer, num uint64) (int64, error)

WriteUint64 writes the uint64 number to the writer

func WriteUint8

func WriteUint8(w io.Writer, num uint8) (int64, error)

WriteUint8 writes the uint8 number to the writer

Types

This section is empty.

Jump to

Keyboard shortcuts

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