Update bytes.go

This commit is contained in:
lupin17 2026-01-13 21:42:44 +01:00 committed by GitHub
parent 3b17e78274
commit 4ebef16b7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,13 +38,7 @@ func FromHex(s string) []byte {
// CopyBytes returns an exact copy of the provided bytes. // CopyBytes returns an exact copy of the provided bytes.
func CopyBytes(b []byte) (copiedBytes []byte) { func CopyBytes(b []byte) (copiedBytes []byte) {
if b == nil { return bytes.Clone(b)
return nil
}
copiedBytes = make([]byte, len(b))
copy(copiedBytes, b)
return
} }
// has0xPrefix validates str begins with '0x' or '0X'. // has0xPrefix validates str begins with '0x' or '0X'.