mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 21:26:42 +00:00
Update hexutil.go
This commit is contained in:
parent
b04df226fa
commit
55ee07dd6b
1 changed files with 4 additions and 2 deletions
|
|
@ -82,7 +82,8 @@ func MustDecode(input string) []byte {
|
|||
// Encode encodes b as a hex string with 0x prefix.
|
||||
func Encode(b []byte) string {
|
||||
enc := make([]byte, len(b)*2+2)
|
||||
copy(enc, "0x")
|
||||
enc[0] = '0'
|
||||
enc[1] = 'x'
|
||||
hex.Encode(enc[2:], b)
|
||||
return string(enc)
|
||||
}
|
||||
|
|
@ -113,7 +114,8 @@ func MustDecodeUint64(input string) uint64 {
|
|||
// EncodeUint64 encodes i as a hex string with 0x prefix.
|
||||
func EncodeUint64(i uint64) string {
|
||||
enc := make([]byte, 2, 10)
|
||||
copy(enc, "0x")
|
||||
enc[0] = '0'
|
||||
enc[1] = 'x'
|
||||
return string(strconv.AppendUint(enc, i, 16))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue