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

Issues
  • 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
  • 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
  • Reference implementaiton for UUID v8

    Reference implementaiton for UUID v8

    It would be nice to have a reference implementation for UUID v8 as defined here:

    https://www.ietf.org/id/draft-peabody-dispatch-new-uuid-format-03.html

    opened by yepher 1
  • Equals method

    Equals method

    Does an "Equals(uuid1,uuid2)" method actually exists? It's not so fast comparing uuid's by parsing two values in string and then comparing then by '=='.

    opened by oGabrielArruda 1
  • not able to install uuid package

    not able to install uuid package

    RUN go install github.com/google/[email protected] or RUN go install github.com/google/uuid running these command but getting such error, RUN go install github.com/google/[email protected]: #10 0.943 go: downloading github.com/google/uuid v1.3.0 #10 2.980 package github.com/google/uuid is not a main package

    executor failed running [/bin/sh -c go install github.com/google/[email protected]]: exit code: 1

    please give me some solution for same

    opened by syedabbas110 3
  • Panic when uuid.New().String()

    Panic when uuid.New().String()

    I run a horizontally scaled application in k8s producing UUIDs for messages. However, rarely, some replicated pods restart due to a panic coming for the UUID library.

    panic: unexpected EOF                                                                                                                                                                                                                        
    goroutine 197286 [running]:                                                                                                                                                                                                                  
    github.com/google/uuid.Must(...)                                                                                                                                                                                                             
     /home/vagrant/go/pkg/mod/github.com/google/[email protected]/uuid.go:178                                                                                                                                                                      
    github.com/google/uuid.New(...)                                                                                                                                                                                                              
     /home/vagrant/go/pkg/mod/github.com/google/[email protected]/version4.go:14
    

    Is there any OS/library causing these issues, like too little entropy? On my local machine, I run a test producing billions of UUIDs without any panic.

    opened by nfoerster 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 14 Jan 24, 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 927 Jun 24, 2022
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 32 Apr 23, 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.1k Jun 29, 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.6k Jul 3, 2022
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 2k Jun 26, 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 5 Feb 24, 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).

徐连波 187 Jun 20, 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 50 Jun 1, 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 65 Jun 18, 2022
Herbert Fischer 197 Jun 10, 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 509 Jun 22, 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 4 Apr 21, 2022
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 May 18, 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 201 Jul 1, 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 14 Jan 24, 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 927 Jun 24, 2022
Authentication Plugin for implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0, SAML Authentication

Authentication Plugin for implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0, SAML Authentication

Paul Greenberg 432 Jun 25, 2022
Serverless SOAR (Security Orchestration, Automation and Response) framework for automatic inspection and evaluation of security alert

DeepAlert DeepAlert is a serverless framework for automatic response of security alert. Overview DeepAlert receives a security alert that is event of

null 34 Jun 15, 2022
Web-Security-Academy - Web Security Academy, developed in GO

Web-Security-Academy - Web Security Academy, developed in GO

Xavier Llauca 1 Feb 23, 2022
Package json implements encoding and decoding of JSON as defined in RFC 7159

Package json implements encoding and decoding of JSON as defined in RFC 7159. The mapping between JSON and Go values is described in the documentation for the Marshal and Unmarshal functions

High Performance, Kubernetes Native Object Storage 2 Jun 26, 2022
Authentication service that keeps you in control without forcing you to be an expert in web security.

Authentication service that keeps you in control without forcing you to be an expert in web security.

Keratin 1.1k Jun 25, 2022
Package arp implements the ARP protocol, as described in RFC 826. MIT Licensed.

arp Package arp implements the ARP protocol, as described in RFC 826. MIT Licensed. Portions of this code are taken from the Go standard library. The

Matt Layher 287 Jun 22, 2022
Package dhcp6 implements a DHCPv6 server, as described in RFC 3315. MIT Licensed.

dhcp6 Package dhcp6 implements a DHCPv6 server, as described in IETF RFC 3315. MIT Licensed. At this time, the API is not stable, and may change over

Matt Layher 74 May 8, 2022
Rabbitio - Rabbit stream cipher package RFC 4503 for Go

rabbitio rabbitio is a rabbit stream cipher packge based on RFC 4503 for golang

Sina Ghaderi 7 Feb 8, 2022
Implementation of RFC-6238 (Time-Based One-Time Password Algorithm) in Go.

TOTP TOTP (RFC-6238) implementation in Go with no external dependencies. INSTALL You can do little copying the totp.go file or add this package as Go

Sarjono Mukti Aji 1 Jan 18, 2022