Skip to content

Added Feature - Add MustParseBytes to support byte-slice UUID parsing#212

Open
hamid-husain wants to merge 1 commit intogoogle:masterfrom
hamid-husain:MustParseBytes
Open

Added Feature - Add MustParseBytes to support byte-slice UUID parsing#212
hamid-husain wants to merge 1 commit intogoogle:masterfrom
hamid-husain:MustParseBytes

Conversation

@hamid-husain
Copy link
Copy Markdown

This pull request adds the MustParseBytes function to the uuid package.

While the package currently provides MustParse for strings, there was no equivalent helper for []byte inputs. This addition ensures API symmetry and simplifies the initialization of global variables or constants when the source UUID is represented as a byte slice (e.g., from a database driver or network buffer).

Changes

  • Added MustParseBytes([]byte) UUID which wraps ParseBytes.
  • Logic mirrors MustParse, including the panic behavior on failure to ensure it is safe for package-level variable initialization.
  • Includes a descriptive panic message consistent with the existing MustParse implementation.

Example Usage
var namespace = uuid.MustParseBytes([]byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))

Checklists

  • Code follows the existing style of the repository.
  • Function is documented with comments.
  • No breaking changes introduced.

@hamid-husain hamid-husain requested a review from a team as a code owner April 10, 2026 12:41
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 10, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant