• Li, Cheng's avatar
    common: improve printing of Hash and Address (#21834) · bd848aad
    Li, Cheng authored
    Both Hash and Address have a String method, which returns the value as
    hex with 0x prefix. They also had a Format method which tried to print
    the value using printf of []byte. The way Format worked was at odds with
    String though, leading to a situation where fmt.Sprintf("%v", hash)
    returned the decimal notation and hash.String() returned a hex string.
    
    This commit makes it consistent again. Both types now support the %v,
    %s, %q format verbs for 0x-prefixed hex output. %x, %X creates
    unprefixed hex output. %d is also supported and returns the decimal
    notation "[1 2 3...]".
    
    For Address, the case of hex characters in %v, %s, %q output is
    determined using the EIP-55 checksum. Using %x, %X with Address
    disables checksumming.
    Co-authored-by: 's avatarFelix Lange <fjl@twurst.com>
    bd848aad
Name
Last commit
Last update
..
bitutil Loading commit data...
compiler Loading commit data...
fdlimit Loading commit data...
hexutil Loading commit data...
math Loading commit data...
mclock Loading commit data...
prque Loading commit data...
big.go Loading commit data...
bytes.go Loading commit data...
bytes_test.go Loading commit data...
debug.go Loading commit data...
format.go Loading commit data...
path.go Loading commit data...
size.go Loading commit data...
size_test.go Loading commit data...
test_utils.go Loading commit data...
types.go Loading commit data...
types_test.go Loading commit data...