MCPcopy
hub / github.com/gofrs/uuid

github.com/gofrs/uuid @v5.4.0 sqlite

repository ↗ · DeepWiki ↗ · release v5.4.0 ↗
212 symbols 768 edges 11 files 79 documented · 37%
README

UUID

License Build Status Go Reference Coverage Status Go Report Card CodeQL OpenSSF Best Practices OpenSSF Scorecard

Package uuid provides a pure Go implementation of Universally Unique Identifiers (UUID) variant as defined in RFC-9562. This package supports both the creation and parsing of UUIDs in different formats.

This package supports the following UUID versions:

  • Version 1, based on timestamp and MAC address
  • Version 3, based on MD5 hashing of a named value
  • Version 4, based on random numbers
  • Version 5, based on SHA-1 hashing of a named value
  • Version 6, a k-sortable id based on timestamp, and field-compatible with v1
  • Version 7, a k-sortable id based on timestamp

Project History

This project was originally forked from the github.com/satori/go.uuid repository after it appeared to be no longer maintained, while exhibiting critical flaws. We have decided to take over this project to ensure it receives regular maintenance for the benefit of the larger Go community.

We'd like to thank Maxim Bublis for his hard work on the original iteration of the package.

License

This source code of this package is released under the MIT License. Please see the LICENSE for the full content of the license.

Recommended Package Version

We recommend using v2.0.0+ of this package, as versions prior to 2.0.0 were created before our fork of the original package and have some known deficiencies.

Requirements

This package requires Go 1.19 or later

Usage

Here is a quick overview of how to use this package. For more detailed documentation, please see the GoDoc Page.

package main

import (
    "log"

    "github.com/gofrs/uuid/v5"
)

// Create a Version 4 UUID, panicking on error.
// Use this form to initialize package-level variables.
var u1 = uuid.Must(uuid.NewV4())

func main() {
    // Create a Version 4 UUID.
    u2, err := uuid.NewV4()
    if err != nil {
        log.Fatalf("failed to generate UUID: %v", err)
    }
    log.Printf("generated Version 4 UUID %v", u2)

    // Parse a UUID from a string.
    s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
    u3, err := uuid.FromString(s)
    if err != nil {
        log.Fatalf("failed to parse UUID %q: %v", s, err)
    }
    log.Printf("successfully parsed UUID %v", u3)
}

References

Extension points exported contracts — how you extend this code

Generator (Interface)
Generator provides an interface for generating UUIDs. [1 implementers]
generator.go
EpochFunc (FuncType)
EpochFunc is the function type used to provide the current time.
generator.go
HWAddrFunc (FuncType)
HWAddrFunc is the function type used to provide hardware (MAC) addresses.
generator.go
GenOption (FuncType)
GenOption is a function type that can be used to configure a Gen generator.
generator.go

Core symbols most depended-on inside this repo

Error
called by 36
error.go
FromString
called by 33
codec.go
Must
called by 29
uuid.go
String
called by 26
uuid.go
Version
called by 18
uuid.go
NewGenWithOptions
called by 14
generator.go
UnmarshalText
called by 14
codec.go
Variant
called by 11
uuid.go

Shape

Function 155
Method 46
Struct 4
FuncType 3
TypeAlias 3
Interface 1

Languages

Go100%

Modules by API surface

generator_test.go59 symbols
generator.go42 symbols
codec_test.go25 symbols
sql_test.go22 symbols
uuid_test.go19 symbols
uuid.go18 symbols
codec.go11 symbols
sql.go7 symbols
error_test.go6 symbols
error.go2 symbols
parse_test.go1 symbols

For agents

$ claude mcp add uuid \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact