bytes

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package bytes offers convenience functions to convert bytes to and from unsigned integers, respecting a defined byte-order.

The underlying byte order and conversion methods being used stem from the encoding/binary package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Endian defines the byte order used for the encoding.
	Endian binary.ByteOrder = binary.BigEndian
	// ErrInvalidLen is an error indicating that a byte slice had invalid length
	// for the conversion that should have been performed.
	ErrInvalidLen = errors.New("invalid byte length")
)

Functions

func FromUint16

func FromUint16(v uint16) (data []byte)

FromUint16 converts an uint16 to a byte slice.

func FromUint32

func FromUint32(v uint32) (data []byte)

FromUint32 converts an uint32 to a byte slice.

func FromUint64

func FromUint64(v uint64) (data []byte)

FromUint64 converts an uint64 to a byte slice.

func ToUint16

func ToUint16(data []byte) (v uint16, err error)

ToUint16 encodes the byte slice to an uint16.

func ToUint32

func ToUint32(data []byte) (v uint32, err error)

ToUint32 encodes the byte slice to an uint32.

func ToUint64

func ToUint64(data []byte) (v uint64, err error)

ToUint64 encodes the byte slice to an uint64.

Types

This section is empty.

Jump to

Keyboard shortcuts

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