Conversation
|
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. |
uuid.go
Outdated
| } | ||
|
|
||
| // Bytes returns the bytes form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
| // , or "" if uuid is invalid. |
There was a problem hiding this comment.
This function cannot fail so there should just be a period at the end of line 197.
uuid_test.go
Outdated
| } | ||
| } | ||
|
|
||
| func TestBytes(t *testing.T) { |
There was a problem hiding this comment.
This test is not actually required. Instead, TestCoding should be modified to include a test of Bytes().
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
b81bbcf to
9e5f57d
Compare
func (uuid UUID) StringBytes() []byte {
var buf [36]byte
encodeHex(buf[:], uuid)
return buf[:]
}
func (uuid UUID) Bytes() []byte{
return uuid[:]
}这样实现是不是更好? |
|
@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? |
summary
add
Bytes()for uuid object.