Update hexutil.go

This commit is contained in:
Justin 2025-11-25 22:55:45 +01:00 committed by GitHub
parent b04df226fa
commit 55ee07dd6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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))
}