bytes

package
v0.0.0-...-517aab8 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Concat

func Concat(src ...[]byte) []byte

Concat an array of bytes.

func FromI08

func FromI08(val int8) []byte

FromI08 converts int8 to bytes(little endian).

func FromI16

func FromI16(val int16) []byte

FromI16 converts int16 to bytes(little endian).

func FromI32

func FromI32(val int32) []byte

FromI32 converts int32 to bytes(little endian).

func FromI64

func FromI64(val int64) []byte

FromI64 converts int64 to bytes(little endian).

func FromU08

func FromU08(val uint8) []byte

FromU08 converts uint8 to bytes(little endian).

func FromU16

func FromU16(val uint16) []byte

FromU16 converts uint16 to bytes(little endian).

func FromU32

func FromU32(val uint32) []byte

FromU32 converts uint32 to bytes(little endian).

func FromU64

func FromU64(val uint64) []byte

FromU64 converts uint64 to bytes(little endian).

func ToHexString

func ToHexString(src []byte, lim int) (dst string)

ToHexString convert a `src` to string and intercept the first n characters. If `lim` is 0, there is no limits.

func ToI08

func ToI08(val []byte) int8

ToI08 converts bytes to int8 (little endian).

func ToI16

func ToI16(val []byte) int16

ToI16 converts bytes to int16 (little endian).

func ToI32

func ToI32(val []byte) int32

ToI32 converts bytes to int32 (little endian).

func ToI64

func ToI64(val []byte) int64

ToI64 converts bytes to int64 (little endian).

func ToU08

func ToU08(val []byte) uint8

ToU08 convert bytes(little endian) to uint8.

func ToU16

func ToU16(val []byte) uint16

ToU16 convert bytes(little endian) to uint16.

func ToU32

func ToU32(val []byte) uint32

ToU32 convert bytes(little endian) to uint32.

func ToU64

func ToU64(val []byte) uint64

ToU64 convert bytes(little endian) to uint32.

Types

type HexBytes

type HexBytes []byte

HexBytes enables HEX-encoding for json/encoding.

func (HexBytes) Bytes

func (bz HexBytes) Bytes() []byte

Bytes fulfills various interfaces in light-client, etc...

func (HexBytes) Format

func (bz HexBytes) Format(s fmt.State, verb rune)

Format writes either address of 0th element in a slice in base 16 notation, with leading 0x (%p), or casts HexBytes to bytes and writes as hexadecimal string to s.

func (HexBytes) Marshal

func (bz HexBytes) Marshal() ([]byte, error)

Marshal needed for protobuf compatibility

func (HexBytes) MarshalJSON

func (bz HexBytes) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. The encoding is a JSON quoted string of hexadecimal digits.

func (HexBytes) String

func (bz HexBytes) String() string

func (*HexBytes) Unmarshal

func (bz *HexBytes) Unmarshal(data []byte) error

Unmarshal needed for protobuf compatibility

func (*HexBytes) UnmarshalJSON

func (bz *HexBytes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Umarshaler interface.

Jump to

Keyboard shortcuts

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