Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.

uuid build status

The uuid package generates and inspects UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.

This package is based on the github.com/pborman/uuid package (previously named code.google.com/p/go-uuid). It differs from these earlier packages in that a UUID is a 16 byte array rather than a byte slice. One loss due to this change is the ability to represent an invalid UUID (vs a NIL UUID).

Install

go get github.com/google/uuid

Documentation

GoDoc

Full go doc style documentation for the package can be viewed online without installing this package by using the GoDoc site here: http://pkg.go.dev/github.com/google/uuid

Owner
Google
Google ❤️ Open Source
Google
Comments
  • feat(uuid): Added support for NullUUID

    feat(uuid): Added support for NullUUID

    Per the discussion in #54, this introduces a NullUUID type to the package that works like other nullable types in the database/sql package. Figured I'd just get the PR out while I'm playing around in this space.

  • Release/Tag new version

    Release/Tag new version

    In order to use Go Dep effectively with semver, please release or tag a new version. Using revisions with many open source project dependencies makes Go Dep much less convenient. The latest version is roughly 1 year and 22 commits in the past thus I could argue a new version is likely. It also seems lately new features were thus further strengthen the idea to bump the version.

  • SQL value more efficient at bytes

    SQL value more efficient at bytes

    The SQL Value() gives a string representation of UUID, if this is unindexed data this may make little difference in the performance of the data but where this is either an index or even the PK this not efficient storage. Here's one of many articles on it.

    This could either have a breaking change and make this provide a []byte type. If there is some more dominant SQL DB being targeted which does not benefit from this, then we could minimally have a BytesValuer() function to return a Valuer which does do this.

  • add Version4 factory to configure UUID generation

    add Version4 factory to configure UUID generation

    Adds a Version4 factory struct, which can accumulate options for generating version 4 UUIDs. For now the only option is the io.Reader used for randomness.

    Also reverts #80, as that implementation cannot be used safely in general. Instead, clients should create a factory with a buffered io.Reader implementation.

    Fixes #86.

    cc @pborman

  • Test failures (TestNode, TestNodeID)

    Test failures (TestNode, TestNodeID)

    I'm getting the following test failures with Golang 1.10:

    === RUN   TestNode
    --- FAIL: TestNode (0.00s)
            uuid_test.go:306: NodeInterface returned an empty string
    === RUN   TestNodeID
    --- FAIL: TestNodeID (0.00s)
            uuid_test.go:376: NodeInterface "user" after SetInteface
    
  • JSON parsing of empty strings as uuid.Nil

    JSON parsing of empty strings as uuid.Nil

    Would it be possible/desirable to support parsing empty strings in JSON as uuid.Nil?

    Currently it generates "invalid UUID length: 0": https://play.golang.org/p/K4y-DFj44Z6

  • The func of New() cost more than 9 minute

    The func of New() cost more than 9 minute

    My online app is use this lib by uuid.New(), About 3 million concurrent I found per call of uuid.New() cost more than 9 minutes. I found many mutex in it's call chain. Is there any problems?

  • Use a custom error type for invalid lengths, replacing `fmt.Errorf`

    Use a custom error type for invalid lengths, replacing `fmt.Errorf`

    This significantly improves the speed of failed parses due to wrong lengths. Previously the fmt.Errorf call dominated, making this the most expensive error and more expensive than successfully parsing:

    BenchmarkParse-4                 29226529        36.1 ns/op
    BenchmarkParseBadLength-4         6923106       174 ns/op
    BenchmarkParseLen32Truncated-4   26641954        38.1 ns/op
    BenchmarkParseLen36Corrupted-4   19405598        59.5 ns/op
    

    When the formatting is not required and done on-demand, the failure per se is much faster:

    BenchmarkParse-4                 29641700        36.3 ns/op
    BenchmarkParseBadLength-4        58602537        20.0 ns/op
    BenchmarkParseLen32Truncated-4   30664791        43.6 ns/op
    BenchmarkParseLen36Corrupted-4   18882410        61.9 ns/op
    

    Add benchmarks for different kinds of invalid UUIDs, and a test case for too-short UUIDs to ensure visible behavior doesn’t change.

  • Typos and why does New panic?

    Typos and why does New panic?

    Typos

    'from' is repeated twice in this comment:

    https://godoc.org/github.com/google/uuid#NewRandom

    A note about uniqueness derived from from the UUID Wikipedia entry:

    NewRandom() returns an error, not a panic:

    https://godoc.org/github.com/google/uuid#NewRandom

    NewRandom returns a Random (Version 4) UUID or panics.

    Why does New panic?

    It is surprising New() panics when compared to the html/template package, for example, where functions that panic include the word Must:

    var t = template.Must(template.New("name").Parse("html"))
    

    https://godoc.org/github.com/google/uuid#New

    New ~is~ creates a new random UUID or panics. New is equivalent to the expression

  • Is this package cryptographically secure?

    Is this package cryptographically secure?

    I am working on a legacy app that used UUID v4 as its authentication key. Is that secure? (Some implementations, like python3's are secure, meanwhile others aren't)

    Moving the entire app to crytpo/rand would be way too much.

  • Allow concurrent, re-creatable usage

    Allow concurrent, re-creatable usage

    Related to issue #43. To enable concurrent and re-creatable usage, I have added a UuidSource, similar to the source in math/rand. It holds its own random number generator (the rander). I have added only the methods that seemed relevant: SetRand(), NewRandom() (version 4) and New(). From what I saw, other methods do not use random number generator (except the clock sequence but this can't be recreated anyway).

  • [Documentation] uuid.Nil is not documented properly

    [Documentation] uuid.Nil is not documented properly

    uuid.Nil https://github.com/google/uuid/blob/44b5fee7c49cf3bcdf723f106b36d56ef13ccc88/hash.go#L19 has the documentation Well known namespace IDs and UUIDs (see image below) image but it should probably be empty UUID, all zeros

  • Add custom node ids

    Add custom node ids

    In the current implementation, the generation of version 1 UUIDs using distinct node ids is only possible by sequentially calling "SetNodeID(…); NewUUID()" for each UUID to generate. There also is no sort of locking for this workflow, so we might experience race conditions when generating UUIDs for distinct node ids simultaneously.

    Additionally RFC-4122 section 4.5 suggests to set the u/m bit to 1, when using custom node ids in order to reliably avoid collisions with UUIDs created for node ids which are based on IEEE 802 addresses. This is not (and should not being) checked within the global SetNodeID(...) func.

    So I decided to add a CustomNodeId type which enables this kind of usage in a clean way.

  • fix to use MustParse(

    fix to use MustParse("xxx") instead of Must(Parse("xxxx"))

    Must(Parse("xxxx")) is considered legacy code to forced uuid to parse because the code is pre-implementation of Must(Parase("xxxx"))(https://github.com/google/uuid/pull/26)

    This one is simpler.

  • Is there a method to generate empty UUID v4?

    Is there a method to generate empty UUID v4?

    Hi! I noticed there is a uuid.Nil for UUID v1 but no uuid.Nil (for example uuid.Nil4) for UUID v4 could be useful adding this method to the library? (I could also make a PR)

Related tags
Generate, encode, and decode UUIDs v1 with fast or cryptographic-quality random node identifier.

A Go package for generating and manipulating UUIDs Generate, encode, and decode UUIDs v1, as defined in RFC 4122, in Go. Project Status v1.1.0 Stable:

Sep 27, 2022
A generator library for concise, unambiguous and URL-safe UUIDs

shortuuid A Go library that generates concise, unambiguous, URL-safe UUIDs. Based on and compatible with the Python library shortuuid. Often, one need

Jan 4, 2023
A UUIDv4 generation package written in go

Goid A Go package to generate V4 UUIDs Documentation The API docs can be viewed here or generated with godoc. Usage An example of generating a v4 UUID

Dec 24, 2022
A UUID package originally forked from github.com/satori/go.uuid

UUID Package uuid provides a pure Go implementation of Universally Unique Identifiers (UUID) variant as defined in RFC-4122. This package supports bot

Dec 30, 2022
UUID package for Go

UUID package for Go language This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing

Jan 2, 2023
A simple to use Go (golang) package to generate or parse Twitter snowflake IDs

snowflake snowflake is a Go package that provides A very simple Twitter snowflake generator. Methods to parse existing snowflake IDs. Methods to conve

Dec 30, 2022
✨ Generate unique IDs (Port of Node package "generate-snowflake" to Golang)

✨ Generate Snowflake Generate unique IDs. Inspired by Twitter's Snowflake system. ?? Installation Initialize your project (go mod init example.com/exa

Feb 11, 2022
UUID package for Golang

UUID package for Go language This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing

Dec 9, 2021
Snowflake - A simple to use Go (golang) package to generate or parse Twitter snowflake IDs
Snowflake - A simple to use Go (golang) package to generate or parse Twitter snowflake IDs

❄️ Go-Snowflake A Snowflake Generator for Go A simple to use Go (golang) package

Oct 20, 2022
❄ An Lock Free ID Generator for Golang based on Snowflake Algorithm (Twitter announced).
❄ An Lock Free ID Generator for Golang based on Snowflake Algorithm (Twitter announced).

❄ An Lock Free ID Generator for Golang based on Snowflake Algorithm (Twitter announced).

Dec 14, 2022
A tiny and fast Go unique string generator

Nano ID A tiny and fast Go unique string generator Safe. It uses cryptographically strong random APIs and tests distribution of symbols. Compact. It u

Nov 11, 2022
Compact, sortable and fast unique IDs with embedded metadata.
Compact, sortable and fast unique IDs with embedded metadata.

A spec for unique IDs in distributed systems based on the Snowflake design, i.e. a coordination-based ID variant. It aims to be friendly to both machi

Dec 22, 2022
Oct 8, 2022
A simple uuid library based on RFC 4122

UUID generator A simple library that generates uuids. Supported versions: version 1 version 3 version 4 version 5 Supported variants: DCE Microsoft Th

Oct 20, 2021
A go implementation of the STUN client (RFC 3489 and RFC 5389)

go-stun go-stun is a STUN (RFC 3489, 5389) client implementation in golang (a.k.a. UDP hole punching). RFC 3489: STUN - Simple Traversal of User Datag

Jan 5, 2023
mesh-kridik is an open-source security scanner that performs various security checks on a Kubernetes cluster with istio service mesh and is leveraged by OPA (Open Policy Agent) to enforce security rules.
mesh-kridik is an open-source security scanner that performs various security checks on a Kubernetes cluster with istio service mesh and is leveraged by OPA (Open Policy Agent) to enforce security rules.

mesh-kridik Enhance your Kubernetes service mesh security !! mesh-kridik is an open-source security scanner that performs various security checks on a

Dec 14, 2022
A microservice gateway developed based on golang.With a variety of plug-ins which can be expanded by itself, plug and play. what's more,it can quickly help enterprises manage API services and improve the stability and security of API services.
A microservice gateway developed based on golang.With a variety of plug-ins which can be expanded by itself, plug and play. what's more,it can quickly help enterprises manage API services and improve the stability and security of API services.

Goku API gateway is a microservice gateway developed based on golang. It can achieve the purposes of high-performance HTTP API forwarding, multi tenant management, API access control, etc. it has a powerful custom plug-in system, which can be expanded by itself, and can quickly help enterprises manage API services and improve the stability and security of API services.

Dec 29, 2022
List running processes that are acting as DCE/RPC servers or clients

rpcls This project was made to assist in a larger research project. It pulls from a running process' PEB to enumerate the loaded DLLs. If a process im

Sep 14, 2022
Generate, encode, and decode UUIDs v1 with fast or cryptographic-quality random node identifier.

A Go package for generating and manipulating UUIDs Generate, encode, and decode UUIDs v1, as defined in RFC 4122, in Go. Project Status v1.1.0 Stable:

Sep 27, 2022
A generator library for concise, unambiguous and URL-safe UUIDs

shortuuid A Go library that generates concise, unambiguous, URL-safe UUIDs. Based on and compatible with the Python library shortuuid. Often, one need

Jan 4, 2023