Documentation ¶
Index ¶
- Variables
- func Encode(b []byte) string
- func EncodeTs(number uint64) []byte
- func FromHex(s string) []byte
- func Has0xPrefix(str string) bool
- func Hex2Bytes(str string) []byte
- func IsHex(str string) bool
- func MustDecodeHex(in string) []byte
- func MustDecodeString(s string) []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 ( ErrMissingPrefix = &decError{"hex string without 0x prefix"} ErrOddLength = &decError{"hex string of odd length"} ErrSyntax = &decError{"invalid hex string"} )
Functions ¶
func Has0xPrefix ¶
Has0xPrefix validates str begins with '0x' or '0X'.
func MustDecodeHex ¶
func MustDecodeString ¶
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.