byteutils

package
v0.0.0-...-84d53aa Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2Hex

func Bytes2Hex(d []byte) string

Bytes2Hex encodes bytes and returns hex string without '0x' prefix

func BytesSlice2HexSlice

func BytesSlice2HexSlice(d [][]byte) []string

BytesSlice2HexSlice encodes bytes slice and returns hex string slice without '0x' prefix

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

CopyBytes returns a copied clone of the bytes

func Decode

func Decode(data []byte, dec Decoder) (interface{}, error)

Decode decodes []byte from Decoder.

func Encode

func Encode(s interface{}, enc Encoder) ([]byte, error)

Encode encodes object to Encoder.

func Equal

func Equal(a []byte, b []byte) bool

Equal checks whether byte slice a and b are equal.

func FromHex

func FromHex(s string) ([]byte, error)

FromHex returns decoded bytes array from hex string

func FromInt16

func FromInt16(v int16) []byte

FromInt16 decodes int16 v.

func FromInt32

func FromInt32(v int32) []byte

FromInt32 decodes int32 v.

func FromInt64

func FromInt64(v int64) []byte

FromInt64 decodes int64 v.

func FromUint16

func FromUint16(v uint16) []byte

FromUint16 decodes uint16.

func FromUint32

func FromUint32(v uint32) []byte

FromUint32 decodes uint32.

func FromUint64

func FromUint64(v uint64) []byte

FromUint64 decodes unit64 value.

func HasHexPrefix

func HasHexPrefix(str string) bool

HasHexPrefix checks if hex string has '0x' or '0X' prefix

func Hex2Bytes

func Hex2Bytes(str string) ([]byte, error)

Hex2Bytes decodes hex string without '0x' prefix and returns bytes

func HexSlice2BytesSlice

func HexSlice2BytesSlice(ss []string) ([][]byte, error)

HexSlice2BytesSlice decodes hex string slice without '0x' prefix and returns bytes slice

func Int16

func Int16(data []byte) int16

Int16 encode []byte.

func Int32

func Int32(data []byte) int32

Int32 encodes []byte.

func Int64

func Int64(data []byte) int64

Int64 encodes []byte.

func IsHex

func IsHex(str string) bool

IsHex checks if a string is hex representation

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

LeftPadBytes adds padding in left side

func RightPadBytes

func RightPadBytes(slice []byte, l int) []byte

RightPadBytes adds padding in right side

func ToHex

func ToHex(b []byte) string

ToHex returns hex string of bytes

func Uint16

func Uint16(data []byte) uint16

Uint16 encodes []byte.

func Uint32

func Uint32(data []byte) uint32

Uint32 encodes []byte.

func Uint64

func Uint64(data []byte) uint64

Uint64 encodes []byte.

Types

type Decoder

type Decoder interface {
	DecodeFromBytes(data []byte) (interface{}, error)
}

Decoder is decoder for byteutils.Decode().

type Encoder

type Encoder interface {
	EncodeToBytes(s interface{}) ([]byte, error)
}

Encoder is encoder for byteutils.Encode().

Jump to

Keyboard shortcuts

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