type UUID … type Version … type Variant … const Invalid … const RFC4122 … const Reserved … const Microsoft … const Future … const randPoolSize … var rander … var poolEnabled … var poolMu … var poolPos … var pool … type invalidLengthError … func (err invalidLengthError) Error() string { … } // IsInvalidLengthError is matcher function for custom error invalidLengthError func IsInvalidLengthError(err error) bool { … } // 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) { … } // ParseBytes is like Parse, except it parses a byte slice instead of a string. func ParseBytes(b []byte) (UUID, error) { … } // MustParse is like Parse but panics if the string cannot be parsed. // It simplifies safe initialization of global variables holding compiled UUIDs. func MustParse(s string) UUID { … } // FromBytes creates a new UUID from a byte slice. Returns an error if the slice // does not have a length of 16. The bytes are copied from the slice. func FromBytes(b []byte) (uuid UUID, err error) { … } // Must returns uuid if err is nil and panics otherwise. func Must(uuid UUID, err error) UUID { … } // Validate returns an error if s is not a properly formatted UUID in one of the following formats: // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} // It returns an error if the format is invalid, otherwise nil. func Validate(s string) error { … } // String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx // , or "" if uuid is invalid. func (uuid UUID) String() string { … } // URN returns the RFC 2141 URN form of uuid, // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, or "" if uuid is invalid. func (uuid UUID) URN() string { … } func encodeHex(dst []byte, uuid UUID) { … } // Variant returns the variant encoded in uuid. func (uuid UUID) Variant() Variant { … } // Version returns the version of uuid. func (uuid UUID) Version() Version { … } func (v Version) String() string { … } func (v Variant) String() string { … } // SetRand sets the random number generator to r, which implements io.Reader. // If r.Read returns an error when the package requests random data then // a panic will be issued. // // Calling SetRand with nil sets the random number generator to the default // generator. func SetRand(r io.Reader) { … } // EnableRandPool enables internal randomness pool used for Random // (Version 4) UUID generation. The pool contains random bytes read from // the random number generator on demand in batches. Enabling the pool // may improve the UUID generation throughput significantly. // // Since the pool is stored on the Go heap, this feature may be a bad fit // for security sensitive applications. // // Both EnableRandPool and DisableRandPool are not thread-safe and should // only be called when there is no possibility that New or any other // UUID Version 4 generation function will be called concurrently. func EnableRandPool() { … } // DisableRandPool disables the randomness pool if it was previously // enabled with EnableRandPool. // // Both EnableRandPool and DisableRandPool are not thread-safe and should // only be called when there is no possibility that New or any other // UUID Version 4 generation function will be called concurrently. func DisableRandPool() { … } type UUIDs … // Strings returns a string slice containing the string form of each UUID in uuids. func (uuids UUIDs) Strings() []string { … }