Debian Codegraph @

README.md

raw symbols SCIP
1 # UUID
2
3 [![License](https://img.shields.io/github/license/gofrs/uuid.svg)](https://github.com/gofrs/uuid/blob/master/LICENSE)
4 [![Build Status](https://github.com/gofrs/uuid/actions/workflows/go.yml/badge.svg)](https://github.com/gofrs/uuid/actions/workflows/go.yml)
5 [![Go Reference](https://pkg.go.dev/badge/github.com/gofrs/uuid/v5.svg)](https://pkg.go.dev/github.com/gofrs/uuid/v5)
6 [![Coverage Status](https://codecov.io/gh/gofrs/uuid/branch/master/graphs/badge.svg?branch=master)](https://codecov.io/gh/gofrs/uuid/)
7 [![CodeQL](https://github.com/gofrs/uuid/actions/workflows/codeql.yml/badge.svg)](https://github.com/gofrs/uuid/actions/workflows/codeql.yml)
8 [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8929/badge)](https://www.bestpractices.dev/projects/8929)
9 [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/gofrs/uuid/badge)](https://scorecard.dev/viewer/?uri=github.com/gofrs/uuid)
10
11 Package uuid provides a pure Go implementation of Universally Unique Identifiers
12 (UUID) variant as defined in RFC-9562. This package supports both the creation
13 and parsing of UUIDs in different formats.
14
15 This package supports the following UUID versions:
16
17 * Version 1, based on timestamp and MAC address
18 * Version 3, based on MD5 hashing of a named value
19 * Version 4, based on random numbers
20 * Version 5, based on SHA-1 hashing of a named value
21 * Version 6, a k-sortable id based on timestamp, and field-compatible with v1
22 * Version 7, a k-sortable id based on timestamp
23 * Version 8, for custom UUID implementations
24
25 ## Project History
26
27 This project was originally forked from the
28 [github.com/satori/go.uuid](https://github.com/satori/go.uuid) repository after
29 it appeared to be no longer maintained, while exhibiting [critical
30 flaws](https://github.com/satori/go.uuid/issues/73). We have decided to take
31 over this project to ensure it receives regular maintenance for the benefit of
32 the larger Go community.
33
34 We'd like to thank Maxim Bublis for his hard work on the original iteration of
35 the package.
36
37 ## License
38
39 This source code of this package is released under the MIT License. Please see
40 the [LICENSE](https://github.com/gofrs/uuid/blob/master/LICENSE) for the full
41 content of the license.
42
43 ## Recommended Package Version
44
45 We recommend using v2.0.0+ of this package, as versions prior to 2.0.0 were
46 created before our fork of the original package and have some known
47 deficiencies.
48
49 ## Requirements
50
51 This package requires Go 1.25 or later
52
53 ## Usage
54
55 Here is a quick overview of how to use this package. For more detailed
56 documentation, please see the [GoDoc Page](http://godoc.org/github.com/gofrs/uuid).
57
58 ```go
59 package main
60
61 import (
62 "log"
63
64 "github.com/gofrs/uuid/v5"
65 )
66
67 // Create a Version 4 UUID, panicking on error.
68 // Use this form to initialize package-level variables.
69 var u1 = uuid.Must(uuid.NewV4())
70
71 func main() {
72 // Create a Version 4 UUID.
73 u2, err := uuid.NewV4()
74 if err != nil {
75 log.Fatalf("failed to generate UUID: %v", err)
76 }
77 log.Printf("generated Version 4 UUID %v", u2)
78
79 // Parse a UUID from a string.
80 s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
81 u3, err := uuid.FromString(s)
82 if err != nil {
83 log.Fatalf("failed to parse UUID %q: %v", s, err)
84 }
85 log.Printf("successfully parsed UUID %v", u3)
86 }
87 ```
88
89 ## References
90
91 - [RFC-9562](https://tools.ietf.org/html/rfc9562) (replaces RFC-4122)
92 - [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01)