Skip to content

Commit

Permalink
Clarify the documentation of Parse to state its job is to parse, not …
Browse files Browse the repository at this point in the history
…validate, strings. (#135)
  • Loading branch information
bormanp authored Oct 26, 2023
1 parent cd5fbbd commit 7c22e97
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ func IsInvalidLengthError(err error) bool {
return ok
}

// Parse decodes s into a UUID or returns an error. Both the standard UUID
// forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and
// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the
// Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and the raw hex
// encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
// Parse decodes s into a UUID or returns an error if it cannot be parsed. Both
// the standard UUID forms defined in RFC 4122
// (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and
// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) are decoded. In addition,
// Parse accepts non-standard strings such as the raw hex encoding
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx and 38 byte "Microsoft style" encodings,
// e.g. {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}. Only the middle 36 bytes are
// examined in the latter case. Parse should not be used to validate strings as
// it parses non-standard encodings as indicated above.
func Parse(s string) (UUID, error) {
var uuid UUID
switch len(s) {
Expand Down

0 comments on commit 7c22e97

Please sign in to comment.