Documentation ¶
Overview ¶
Package util provides common utility functions.
Index ¶
- Variables
- func Base64Decode(dst, src []byte) error
- func Base64Encode(src []byte) []byte
- func Encode(b []byte) string
- func FromHex(s string) []byte
- func Uint64ToBytesBigEndian(i uint64) []byte
- func UnmarshalFixedJSON(typ reflect.Type, input, out []byte) error
- func UnmarshalFixedText(typename string, input, out []byte) error
- type Bytes
Constants ¶
This section is empty.
Variables ¶
var ( ErrSyntax = errors.New("invalid hex string") ErrMissingPrefix = errors.New("hex string without 0x prefix") ErrOddLength = errors.New("hex string of odd length") ErrUint64Range = errors.New("hex number > 64 bits") )
Errors.
Functions ¶
func Base64Decode ¶ added in v1.0.0
func Base64Encode ¶ added in v1.0.0
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. Parameter s may be prefixed with "0x".
func Uint64ToBytesBigEndian ¶
Uint64ToBytesBigEndian returns the byte representation of a uint64, using big endian encoding (which is not the default for spacemesh).
func UnmarshalFixedJSON ¶
UnmarshalFixedJSON decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalJSON method for fixed-size types.
func UnmarshalFixedText ¶
UnmarshalFixedText decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.
Types ¶
type Bytes ¶
type Bytes []byte
Bytes marshals/unmarshals as a JSON string with 0x prefix. The empty slice marshals as "0x".
func (Bytes) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Bytes) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Bytes) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.