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

Related tags

UUID Libraries go uuid
Overview

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

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.

    opened by sejr 14
  • 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.

    opened by djui 14
  • 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.

    opened by japettyjohn 9
  • 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

    opened by rittneje 8
  • 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
    
    opened by onlyjob 8
  • 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

    opened by maxekman 7
  • 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?

    opened by Anteoy 7
  • 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.

    opened by joewreschnig 6
  • 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

    opened by corburn 5
  • 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.

    opened by dragonDScript 4
  • 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).

    opened by trabetti 4
  • [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

    opened by slashformotion 0
  • 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.

    opened by tkarrass 1
  • 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.

    opened by kotaroyamazaki 1
  • 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)

    opened by fulviodenza 0
Releases(v1.3.0)
  • v1.3.0(Jul 12, 2021)

    From Andrey Pechkurov:

    Adds an optional randomness pool mode 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. That's why it's implemented as an opt-in feature.

    From Samuel Roth:

    Added support for NullUUID

    A NullUUID can be marked not valid (i.e., null) for use with JSON and the database/sql/driver.Scanner interfaces.

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Jan 22, 2021)

  • v1.1.5(Jan 15, 2021)

    There are no code changes. A missing period was add to a godoc comment and the linter was told to not complain that the results of hash.Write() are ignored (the function cannot fail)

    Source code(tar.gz)
    Source code(zip)
  • v1.1.4(Jan 4, 2021)

  • v1.1.3(Dec 30, 2020)

    Optimize length of time it takes to discover an input is bad by no longer using fmt.Errorf, which is quite slow. It now uses a custom error type that formats the string when the Error method is called rather than when generating the error.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.2(Aug 28, 2020)

    This release contains

    • Allow concurrent, re-creatable usage #44 by trabetti was merged on Apr 16, 2019
    • Fix race in NewUUID() #64 by AstolfoKawaii was merged on Jul 2, 2020
    • Minor formatting and typo fixes
    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(Feb 27, 2019)

  • v1.1.0(Nov 20, 2018)

    This release includes the MustParse as well as parsing of

    Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} Raw hex encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Aug 28, 2018)

  • 1.0.0(Aug 27, 2018)

  • 0.2(Feb 6, 2017)

  • v0.1(Feb 19, 2016)

  • v0(Feb 19, 2016)

Owner
Google
Google ❤️ Open Source
Google
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:

AGExt 15 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

Peter Lithammer 983 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

Jake Langford 37 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

The Go Commune 1.2k 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

Maxim Bublis 4.7k 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

null 2.3k 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

Barış DEMİRCİ 6 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

Maxim Bublis 4.4k Dec 9, 2021
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

houseme 7 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).

徐连波 207 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

Dair Aidarkhanov 56 Nov 11, 2022
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

null 75 Dec 22, 2022
Herbert Fischer 198 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

Vitor Oliveira 0 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

Cong Ding 546 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 Enhance your Kubernetes service mesh security !! mesh-kridik is an open-source security scanner that performs various security checks on a

chenk 22 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.

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.

Eolink 378 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

Alex Flores 5 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:

AGExt 15 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

Peter Lithammer 983 Jan 4, 2023