Documentation
¶
Index ¶
Constants ¶
const (
// HashLength is the expected length of the hash
HashLength = 32
)
Variables ¶
var ( ErrEmptyString = &decError{"empty hex string"} ErrSyntax = &decError{"invalid hex string"} ErrMissingPrefix = &decError{"hex string without 0x prefix"} ErrOddLength = &decError{"hex string of odd length"} ErrEmptyNumber = &decError{"hex string \"0x\""} ErrLeadingZero = &decError{"hex number with leading zero digits"} ErrUint64Range = &decError{"hex number > 64 bits"} ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", uintBits)} ErrBig256Range = &decError{"hex number > 256 bits"} )
Errors
Functions ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func MustDecodeHex ¶
MustDecodeHex decodes a hex string with 0x prefix. It panics for invalid input.
func UnmarshalFixedHexText ¶
UnmarshalFixedHexText 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 Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
type HexBytes ¶
type HexBytes []byte
HexBytes marshals/unmarshals as a JSON string with 0x prefix. The empty slice marshals as "0x".
func (HexBytes) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*HexBytes) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*HexBytes) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.