Documentation ¶
Index ¶
- Variables
- func Decode(input string) ([]byte, error)
- func DecodeBig(input string) (*big.Int, error)
- func DecodeUint64(input string) (uint64, error)
- func Encode(b []byte) string
- func EncodeBig(bigint *big.Int) string
- func EncodeUint64(i uint64) string
- func MustDecode(input string) []byte
- func MustDecodeBig(input string) *big.Int
- func MustDecodeUint64(input string) uint64
- func UnmarshalAddrFixedJSON(typ reflect.Type, input, out []byte) error
- func UnmarshalAddrFixedText(typname string, input, out []byte) error
- func UnmarshalFixedJSON(typ reflect.Type, input, out []byte) error
- func UnmarshalFixedText(typname string, input, out []byte) error
- func UnmarshalFixedUnprefixedText(typname string, input, out []byte) error
- type Big
- type Bytes
- type Uint
- type Uint64
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
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"} )
Functions ¶
func DecodeUint64 ¶
func EncodeUint64 ¶
func MustDecode ¶
func MustDecodeBig ¶
func MustDecodeUint64 ¶
func UnmarshalAddrFixedJSON ¶
func UnmarshalAddrFixedText ¶
func UnmarshalFixedText ¶
Example ¶
package main import ( "encoding/json" "fmt" "github.com/neatlab/neatio/utilities/common/hexutil" ) type MyType [5]byte func (v *MyType) UnmarshalText(input []byte) error { return hexutil.UnmarshalFixedText("MyType", input, v[:]) } func (v MyType) String() string { return hexutil.Bytes(v[:]).String() } func main() { var v1, v2 MyType fmt.Println("v1 error:", json.Unmarshal([]byte(`"0x01"`), &v1)) fmt.Println("v2 error:", json.Unmarshal([]byte(`"0x0101010101"`), &v2)) fmt.Println("v2:", v2) }
Output:
Types ¶
type Bytes ¶
type Bytes []byte
func (Bytes) MarshalText ¶
func (*Bytes) UnmarshalJSON ¶
func (*Bytes) UnmarshalText ¶
type Uint ¶
type Uint uint
func (Uint) MarshalText ¶
func (*Uint) UnmarshalJSON ¶
func (*Uint) UnmarshalText ¶
type Uint64 ¶
type Uint64 uint64
func (Uint64) MarshalText ¶
func (*Uint64) UnmarshalJSON ¶
func (*Uint64) UnmarshalText ¶
Click to show internal directories.
Click to hide internal directories.