uuid icon indicating copy to clipboard operation
uuid copied to clipboard

feat: add uuid bytes

Open rfyiamcool opened this issue 2 years ago • 3 comments

summary

add Bytes() for uuid object.

rfyiamcool avatar Nov 24 '23 03:11 rfyiamcool

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Nov 24 '23 03:11 google-cla[bot]

func (uuid UUID) StringBytes() []byte {
 	var buf [36]byte
 	encodeHex(buf[:], uuid)
 	return buf[:]
 }

func (uuid UUID) Bytes() []byte{
 	return uuid[:] 
}

这样实现是不是更好? Is it better to implement it this way? @rfyiamcool @bormanp

it512 avatar Dec 09 '23 17:12 it512

@it512 To get the bytes representation of a uuid you just have to say uuid[:] as you suggest, there is no reason for a function call. I believe the rationale behind Bytes() is to prevent the conversion from []byte -> string -> []byte. Do you have an alternate suggestion for the functions name? HexBytes?

bormanp avatar Dec 11 '23 16:12 bormanp