encoding

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package encoding provides encoding utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDecoding indicates a decoding error.
	ErrDecoding = errors.New("decoding error")

	// ErrHeaderLength indicates that the header length is insufficient for decoding.
	ErrHeaderLength = errors.New("insufficient header length for decoding")

	// ErrTotalLength indicates that the total length is insufficient for decoding.
	ErrTotalLength = errors.New("insufficient total length for decoding")

	// ErrMissingOutput indicates that no output slice was provided for decoding.
	ErrMissingOutput = errors.New("missing output slice for decoding")

	// ErrNilOutput indicates that a nil output slice was provided for decoding.
	ErrNilOutput = errors.New("nil output slice for decoding")

	// ErrEmptyEncoded indicates that the decoding returned empty data.
	ErrEmptyEncoded = errors.New("decoding yielded empty data")
)

Encoding/decoding errors.

View Source
var (
	// ErrInputNegative happens when the provider integer is negative.
	ErrInputNegative = errors.New("negative input")

	// ErrInputLarge happens when the provider value is too large for the specified length.
	ErrInputLarge = errors.New("input value is too high for length")

	// ErrLengthNegativeOrZero happens when the specified length is negative or 0.
	ErrLengthNegativeOrZero = errors.New("length is negative or 0")

	// ErrLengthTooBig happens when the specified length is > 4.
	ErrLengthTooBig = errors.New("requested length is > 4")

	// ErrInputEmpty happens when the input is nil or empty.
	ErrInputEmpty = errors.New("nil or empty input")

	// ErrInputTooLarge happens when the input is longer than 4 bytes.
	ErrInputTooLarge = errors.New("input too large for integer")
)

I2OSP/OS2IP errors.

Functions

func Concat added in v0.10.0

func Concat(a, b []byte) []byte

Concat returns the concatenation of the two input byte strings.

func Concat3 added in v0.10.0

func Concat3(a, b, c []byte) []byte

Concat3 returns the concatenation of the three input byte strings.

func Concatenate added in v0.10.0

func Concatenate(input ...[]byte) []byte

Concatenate takes the variadic array of input and returns a concatenation of it.

func DecodeLongVector added in v0.10.0

func DecodeLongVector(in []byte, out ...*[]byte) error

DecodeLongVector decodes a vector of concatenated 2-byte length-prefixed byte slices, and stores the encoded slices in the provided output slice.

func DecodeVector added in v0.10.0

func DecodeVector(in []byte) (data []byte, offset int, err error)

DecodeVector returns the byte-slice of length indexed in the first two bytes.

func EncodeVector added in v0.10.0

func EncodeVector(input []byte) []byte

EncodeVector returns the input with a two-byte encoding of its length.

func EncodeVectorLen added in v0.10.0

func EncodeVectorLen(input []byte, length uint16) []byte

EncodeVectorLen returns the input prepended with a byte encoding of its length.

func I2OSP added in v0.10.0

func I2OSP(value int, length uint16) []byte

I2OSP 32-bit Integer to Octet Stream Primitive on maximum 4 bytes.

func OS2IP added in v0.10.0

func OS2IP(input []byte) int

OS2IP Octet Stream to Integer Primitive on maximum 4 bytes / 32 bits.

func SuffixString added in v0.10.0

func SuffixString(a []byte, b string) []byte

SuffixString returns the concatenation of the input byte string and the string argument.

Types

This section is empty.

Jump to

Keyboard shortcuts

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