package uuid
Import Path
github.com/google/uuid (on go.dev)
Dependency Relation
imports 17 packages, and imported by 10 packages
Involved Source Files
dce.go
Package uuid generates and inspects UUIDs.
UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security
Services.
A UUID is a 16 byte (128 bit) array. UUIDs may be used as keys to
maps or compared directly.
hash.go
marshal.go
node.go
node_net.go
null.go
sql.go
time.go
util.go
uuid.go
version1.go
version4.go
Package-Level Type Names (total 7)
A Domain represents a Version 2 domain
( Domain) String() string
Domain : github.com/ChrisTrenkamp/goxpath/tree.Result
Domain : fmt.Stringer
func UUID.Domain() Domain
func NewDCESecurity(domain Domain, id uint32) (UUID, error)
const Group
const Org
const Person
NullUUID represents a UUID that may be null.
NullUUID implements the SQL driver.Scanner interface so
it can be used as a scan destination:
var u uuid.NullUUID
err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&u)
...
if u.Valid {
// use u.UUID
} else {
// NULL value
}
UUID UUID
// Valid is true if UUID is not NULL
MarshalBinary implements encoding.BinaryMarshaler.
MarshalJSON implements json.Marshaler.
MarshalText implements encoding.TextMarshaler.
Scan implements the SQL driver.Scanner interface.
UnmarshalBinary implements encoding.BinaryUnmarshaler.
UnmarshalJSON implements json.Unmarshaler.
UnmarshalText implements encoding.TextUnmarshaler.
Value implements the driver Valuer interface.
*NullUUID : database/sql.Scanner
NullUUID : database/sql/driver.Valuer
NullUUID : encoding.BinaryMarshaler
*NullUUID : encoding.BinaryUnmarshaler
NullUUID : encoding.TextMarshaler
*NullUUID : encoding.TextUnmarshaler
NullUUID : encoding/json.Marshaler
*NullUUID : encoding/json.Unmarshaler
A Time represents a time as the number of 100's of nanoseconds since 15 Oct
1582.
UnixTime converts t the number of seconds and nanoseconds using the Unix
epoch of 1 Jan 1970.
func GetTime() (Time, uint16, error)
func UUID.Time() Time
A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC
4122.
ClockSequence returns the clock sequence encoded in uuid.
The clock sequence is only well defined for version 1 and 2 UUIDs.
Domain returns the domain for a Version 2 UUID. Domains are only defined
for Version 2 UUIDs.
ID returns the id for a Version 2 UUID. IDs are only defined for Version 2
UUIDs.
MarshalBinary implements encoding.BinaryMarshaler.
MarshalText implements encoding.TextMarshaler.
NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is
not valid. The NodeID is only well defined for version 1 and 2 UUIDs.
Scan implements sql.Scanner so UUIDs can be read from databases transparently.
Currently, database types that map to string and []byte are supported. Please
consult database-specific driver documentation for matching types.
String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
, or "" if uuid is invalid.
Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in
uuid. The time is only defined for version 1 and 2 UUIDs.
URN returns the RFC 2141 URN form of uuid,
urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, or "" if uuid is invalid.
UnmarshalBinary implements encoding.BinaryUnmarshaler.
UnmarshalText implements encoding.TextUnmarshaler.
Value implements sql.Valuer so that UUIDs can be written to databases
transparently. Currently, UUIDs map to strings. Please consult
database-specific driver documentation for matching types.
Variant returns the variant encoded in uuid.
Version returns the version of uuid.
UUID : github.com/ChrisTrenkamp/goxpath/tree.Result
*UUID : database/sql.Scanner
UUID : database/sql/driver.Valuer
UUID : encoding.BinaryMarshaler
*UUID : encoding.BinaryUnmarshaler
UUID : encoding.TextMarshaler
*UUID : encoding.TextUnmarshaler
UUID : fmt.Stringer
func FromBytes(b []byte) (uuid UUID, err error)
func Must(uuid UUID, err error) UUID
func MustParse(s string) UUID
func New() UUID
func NewDCEGroup() (UUID, error)
func NewDCEPerson() (UUID, error)
func NewDCESecurity(domain Domain, id uint32) (UUID, error)
func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID
func NewMD5(space UUID, data []byte) UUID
func NewRandom() (UUID, error)
func NewRandomFromReader(r io.Reader) (UUID, error)
func NewSHA1(space UUID, data []byte) UUID
func NewUUID() (UUID, error)
func Parse(s string) (UUID, error)
func ParseBytes(b []byte) (UUID, error)
func github.com/go-co-op/gocron.(*Scheduler).JobsMap() map[UUID]*gocron.Job
func Must(uuid UUID, err error) UUID
func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID
func NewMD5(space UUID, data []byte) UUID
func NewSHA1(space UUID, data []byte) UUID
func github.com/limanmys/render-engine/pkg/cron_jobs.Delete(id *UUID) error
var NameSpaceDNS
var NameSpaceOID
var NameSpaceURL
var NameSpaceX500
var Nil
UUIDs is a slice of UUID types.
Strings returns a string slice containing the string form of each UUID in uuids.
Package-Level Functions (total 27)
ClockSequence returns the current clock sequence, generating one if not
already set. The clock sequence is only used for Version 1 UUIDs.
The uuid package does not use global static storage for the clock sequence or
the last time a UUID was generated. Unless SetClockSequence is used, a new
random clock sequence is generated the first time a clock sequence is
requested by ClockSequence, GetTime, or NewUUID. (section 4.2.1.1)
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.
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.
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.
GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and
clock sequence as well as adjusting the clock sequence as needed. An error
is returned if the current time cannot be determined.
IsInvalidLengthError is matcher function for custom error invalidLengthError
Must returns uuid if err is nil and panics otherwise.
MustParse is like Parse but panics if the string cannot be parsed.
It simplifies safe initialization of global variables holding compiled UUIDs.
New creates a new random UUID or panics. New is equivalent to
the expression
uuid.Must(uuid.NewRandom())
NewDCEGroup returns a DCE Security (Version 2) UUID in the group
domain with the id returned by os.Getgid.
NewDCESecurity(Group, uint32(os.Getgid()))
NewDCEPerson returns a DCE Security (Version 2) UUID in the person
domain with the id returned by os.Getuid.
NewDCESecurity(Person, uint32(os.Getuid()))
NewDCESecurity returns a DCE Security (Version 2) UUID.
The domain should be one of Person, Group or Org.
On a POSIX system the id should be the users UID for the Person
domain and the users GID for the Group. The meaning of id for
the domain Org or on non-POSIX systems is site defined.
For a given domain/id pair the same token may be returned for up to
7 minutes and 10 seconds.
NewHash returns a new UUID derived from the hash of space concatenated with
data generated by h. The hash should be at least 16 byte in length. The
first 16 bytes of the hash are used to form the UUID. The version of the
UUID will be the lower 4 bits of version. NewHash is used to implement
NewMD5 and NewSHA1.
NewMD5 returns a new MD5 (Version 3) UUID based on the
supplied name space and data. It is the same as calling:
NewHash(md5.New(), space, data, 3)
NewRandom returns a Random (Version 4) UUID.
The strength of the UUIDs is based on the strength of the crypto/rand
package.
Uses the randomness pool if it was enabled with EnableRandPool.
A note about uniqueness derived from the UUID Wikipedia entry:
Randomly generated UUIDs have 122 random bits. One's annual risk of being
hit by a meteorite is estimated to be one chance in 17 billion, that
means the probability is about 0.00000000006 (6 × 10−11),
equivalent to the odds of creating a few tens of trillions of UUIDs in a
year and having one duplicate.
NewRandomFromReader returns a UUID based on bytes read from a given io.Reader.
NewSHA1 returns a new SHA1 (Version 5) UUID based on the
supplied name space and data. It is the same as calling:
NewHash(sha1.New(), space, data, 5)
NewString creates a new random UUID and returns it as a string or panics.
NewString is equivalent to the expression
uuid.New().String()
NewUUID returns a Version 1 UUID based on the current NodeID and clock
sequence, and the current time. If the NodeID has not been set by SetNodeID
or SetNodeInterface then it will be set automatically. If the NodeID cannot
be set NewUUID returns nil. If clock sequence has not been set by
SetClockSequence then it will be set automatically. If GetTime fails to
return the current NewUUID returns nil and an error.
In most cases, New should be used.
NodeID returns a slice of a copy of the current Node ID, setting the Node ID
if not already set.
NodeInterface returns the name of the interface from which the NodeID was
derived. The interface "user" is returned if the NodeID was set by
SetNodeID.
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.
ParseBytes is like Parse, except it parses a byte slice instead of a string.
SetClockSequence sets the clock sequence to the lower 14 bits of seq. Setting to
-1 causes a new sequence to be generated.
SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes
of id are used. If id is less than 6 bytes then false is returned and the
Node ID is not set.
SetNodeInterface selects the hardware address to be used for Version 1 UUIDs.
If name is "" then the first usable interface found will be used or a random
Node ID will be generated. If a named interface cannot be found then false
is returned.
SetNodeInterface never fails when name is "".
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.
Package-Level Variables (total 5)
Well known namespace IDs and UUIDs
Well known namespace IDs and UUIDs
Well known namespace IDs and UUIDs
Well known namespace IDs and UUIDs
Well known namespace IDs and UUIDs
Package-Level Constants (total 8)
Constants returned by Variant.
Domain constants for DCE Security (Version 2) UUIDs.
Constants returned by Variant.
Constants returned by Variant.
Domain constants for DCE Security (Version 2) UUIDs.
Domain constants for DCE Security (Version 2) UUIDs.
Constants returned by Variant.
Constants returned by Variant.
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |