Skip to content

Commit 7c22e97

Browse files
authored
Clarify the documentation of Parse to state its job is to parse, not validate, strings. (#135)
1 parent cd5fbbd commit 7c22e97

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Diff for: uuid.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ func IsInvalidLengthError(err error) bool {
5656
return ok
5757
}
5858

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

0 commit comments

Comments
 (0)