google / uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
BSD 3-Clause "New" or "Revised" License
5.26k stars 362 forks source link

The hexadecimal input required by ParseBytes may surprise users #25

Closed JoshuaSjoding closed 6 years ago

JoshuaSjoding commented 6 years ago

When I first encountered the ParseBytes function I was very surprised that it wasn't meant to parse the raw 16 bytes of a uuid, but instead was meant to parse hexadecimal data. I suspect other users of the library will have the same reaction. It turned out that what I actually was looking for was FromBytes.

I realize that it's useful to have a hexadecimal byte-parsing function for performance reasons because it avoids copying data around, but if I hadn't checked the docs I might not have realized I had the wrong function until I received an error from it.

I propose that one of two actions be taken:

  1. Rename ParseBytes to ParseHexBytes to make its intention more clear
  2. Modify ParseBytes to include handling for 16-byte inputs that are then fed into UnmarshalBinary
pborman commented 6 years ago

Renaming the function would be backwards breaking. A well documented change to ParseBytes is probably a better solution. This can be combined with Issue 24.

pborman commented 6 years ago

I will close this issue out as I don't see it changing. Please re-open if you feel strongly about it.