A UUID package originally forked from github.com/satori/go.uuid

Overview

UUID

License Build Status GoDoc Coverage Status Go Report Card

Package uuid provides a pure Go implementation of Universally Unique Identifiers (UUID) variant as defined in RFC-4122. 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 (RFC-4122)
  • Version 3, based on MD5 hashing of a named value (RFC-4122)
  • Version 4, based on random numbers (RFC-4122)
  • Version 5, based on SHA-1 hashing of a named value (RFC-4122)

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.

Installation

It is recommended to use a package manager like dep that understands tagged releases of a package, as well as semantic versioning.

If you are unable to make use of a dependency manager with your project, you can use the go get command to download it directly:

$ go get github.com/gofrs/uuid

Requirements

Due to subtests not being supported in older versions of Go, this package is only regularly tested against Go 1.7+. This package may work perfectly fine with Go 1.2+, but support for these older versions is not actively maintained.

Go 1.11 Modules

As of v3.2.0, this repository no longer adopts Go modules, and v3.2.0 no longer has a go.mod file. As a result, v3.2.0 also drops support for the github.com/gofrs/uuid/v3 import path. Only module-based consumers are impacted. With the v3.2.0 release, all gofrs/uuid consumers should use the github.com/gofrs/uuid import path.

An existing module-based consumer will continue to be able to build using the github.com/gofrs/uuid/v3 import path using any valid consumer go.mod that worked prior to the publishing of v3.2.0, but any module-based consumer should start using the github.com/gofrs/uuid import path when possible and must use the github.com/gofrs/uuid import path prior to upgrading to v3.2.0.

Please refer to Issue #61 and Issue #66 for more details.

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"
)

// 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

Comments
  • Unstable Import Paths

    Unstable Import Paths

    With the introduction of the go.mod file and declaration of github.com/gofrs/uuid/v3 there is no longer a single import path that works correctly for both modules and non-modules users.

    This has become an issue with gobuffalo/pop and other Buffalo projects.

    Below you find a selection of go get statements that represent the different import paths and what happens when trying to use them in different environments.

    Go >1.9.7 (or GO111MODULE=off)

    $ go get github.com/gofrs/uuid/v3
    
    package github.com/gofrs/uuid/v3: cannot find package "github.com/gofrs/uuid/v3" in any of:
        /usr/local/go/src/github.com/gofrs/uuid/v3 (from $GOROOT)
        /go/src/github.com/gofrs/uuid/v3 (from $GOPATH)
    

    Go 1.11 (GO111MODULE=on)

    $ go get github.com/gofrs/uuid
    
    module github.com/gobuffalo/uuidmods
    
    require github.com/gofrs/uuid v3.1.0+incompatible // indirect
    
    $ go get github.com/gofrs/uuid/v3
    
    module github.com/gobuffalo/uuidmods
    
    require (
    	github.com/gofrs/uuid/v3 v3.1.2 // indirect
    )
    
    opened by markbates 62
  • SQL value more efficient as bytes

    SQL value more efficient as bytes

    The SQL Value() gives a string representation of UUID when called. However, storing UUIDs as bytes may be more efficient for some databases. Other UUID libraries have the same issue: https://github.com/google/uuid/issues/20

    Would it be possible to have an option to either set globally to output bytes or a similar approach used for NullUUID?

    I'd be glad to work on a patch in either direction if necessary.

    opened by ricardofandrade 18
  • Implement fmt.Formatter

    Implement fmt.Formatter

    I had a use case where I needed to get the string representation of a UUID with only the hex digits. Implementing fmt.Formatter seems to be the prescribed way to provide custom string formatting in Go, so I did so. Additionally, UUID.String() returns the RFC-compliant string so I did not touch that code.

    The standard %s, %q and %v format runes have the same behavior as before. I added %h and %H for outputting only the hex digits without the dash (-) separators. %h uses 'a'-'f' and %H uses 'A-F'

    opened by dylan-bourque 15
  • Fail under Windows 10 x64

    Fail under Windows 10 x64

    After converting my own project into go.mod and run go test all under module root, got:

    --- FAIL: TestGenerator (0.02s)
    --- FAIL: TestGenerator/NewV2 (0.00s)
    --- FAIL: TestGenerator/NewV2/DifferentAcrossCalls (0.00s)
    generator_test.go:210: generated identical UUIDs across calls: 3912a521-2f04-21e9-8002-309c238cfc62
    FAIL
    FAIL github.com/gofrs/uuid 0.757s
    
    opened by wtask 15
  • Modify codec to avoid heap allocations in the happy path

    Modify codec to avoid heap allocations in the happy path

    UUIDs are implemented as a fixed length array, giving great performance.

    However, while profiling, I've found a few cases in the parsing code that can lead to heap allocations:

    1. Passing values to fmt.Errorf, which accepts interface{}, which typically requires that parameters be boxed
    2. Converting []byte to string or vice versa

    We can avoid these by doing the following:

    1. Copy values passed to fmt.* and friends, which will speed up the happy path
    2. Using some unsafe trickery for []byte <--> string conversion

    This PR implements both of these strategies. As a result, various parsing methods are faster.

    Old benchmark results:

     % go test -benchmem -bench ./...
    goos: linux
    goarch: amd64
    pkg: github.com/gofrs/uuid
    BenchmarkFromString/canonical-8                 10000000               123 ns/op              48 B/op          1 allocs/op
    BenchmarkFromString/urn-8                       10000000               133 ns/op              48 B/op          1 allocs/op
    BenchmarkFromString/braced-8                    10000000               130 ns/op              48 B/op          1 allocs/op
    BenchmarkGenerator/NewV1-8                       1000000              1092 ns/op               0 B/op          0 allocs/op
    BenchmarkGenerator/NewV2-8                       1000000              1095 ns/op               0 B/op          0 allocs/op
    BenchmarkGenerator/NewV3-8                       5000000               273 ns/op             144 B/op          4 allocs/op
    BenchmarkGenerator/NewV4-8                       1000000              1488 ns/op              16 B/op          1 allocs/op
    BenchmarkGenerator/NewV5-8                       5000000               317 ns/op             176 B/op          4 allocs/op
    PASS
    ok      github.com/gofrs/uuid   11.589s
    

    New benchmark results:

     % go test -benchmem -bench ./...
    goos: linux
    goarch: amd64
    pkg: github.com/gofrs/uuid
    BenchmarkFromString/canonical-8                 20000000                87.9 ns/op             0 B/op          0 allocs/op
    BenchmarkFromString/urn-8                       20000000                97.6 ns/op             0 B/op          0 allocs/op
    BenchmarkFromString/braced-8                    20000000                92.2 ns/op             0 B/op          0 allocs/op
    BenchmarkGenerator/NewV1-8                       1000000              1110 ns/op               0 B/op          0 allocs/op
    BenchmarkGenerator/NewV2-8                       1000000              1100 ns/op               0 B/op          0 allocs/op
    BenchmarkGenerator/NewV3-8                       5000000               275 ns/op             144 B/op          4 allocs/op
    BenchmarkGenerator/NewV4-8                       1000000              1485 ns/op              16 B/op          1 allocs/op
    BenchmarkGenerator/NewV5-8                       5000000               322 ns/op             176 B/op          4 allocs/op
    PASS
    ok      github.com/gofrs/uuid   13.213s
    

    Diff:

    % benchcmp old.txt new.txt
    benchmark                           old ns/op     new ns/op     delta
    BenchmarkFromString/canonical-8     128           88.6          -30.78%
    BenchmarkFromString/urn-8           134           101           -24.63%
    BenchmarkFromString/braced-8        131           94.9          -27.56%
    BenchmarkGenerator/NewV1-8          1072          1096          +2.24%
    BenchmarkGenerator/NewV2-8          1078          1111          +3.06%
    BenchmarkGenerator/NewV3-8          271           274           +1.11%
    BenchmarkGenerator/NewV4-8          1471          1506          +2.38%
    BenchmarkGenerator/NewV5-8          318           317           -0.31%
    
    benchmark                           old allocs     new allocs     delta
    BenchmarkFromString/canonical-8     1              0              -100.00%
    BenchmarkFromString/urn-8           1              0              -100.00%
    BenchmarkFromString/braced-8        1              0              -100.00%
    BenchmarkGenerator/NewV1-8          0              0              +0.00%
    BenchmarkGenerator/NewV2-8          0              0              +0.00%
    BenchmarkGenerator/NewV3-8          4              4              +0.00%
    BenchmarkGenerator/NewV4-8          1              1              +0.00%
    BenchmarkGenerator/NewV5-8          4              4              +0.00%
    
    benchmark                           old bytes     new bytes     delta
    BenchmarkFromString/canonical-8     48            0             -100.00%
    BenchmarkFromString/urn-8           48            0             -100.00%
    BenchmarkFromString/braced-8        48            0             -100.00%
    BenchmarkGenerator/NewV1-8          0             0             +0.00%
    BenchmarkGenerator/NewV2-8          0             0             +0.00%
    BenchmarkGenerator/NewV3-8          144           144           +0.00%
    BenchmarkGenerator/NewV4-8          16            16            +0.00%
    BenchmarkGenerator/NewV5-8          176           176           +0.00%
    
    opened by ztstewart 11
  • Add support for providing a custom rand io.Reader

    Add support for providing a custom rand io.Reader

    The current package does not allow me to supply my own io.Reader to use in place of the default rand.Reader. The use case for this is reproducible tests where I can guarantee the same output by providing a rand with a specific seed. Instead, I have to verify in tests that the output of my function is a string in the form of a UUID.

    opened by Willyham 11
  • Towards v2.0.0

    Towards v2.0.0

    This bug tracks development towards a v1.3.0 release and a more formal announcement of the library.

    • as far as I can tell, we have kept backwards API compatibility, so we don't need a major version bump
    • we added new API in #9, which warrants a minor version bump
    • #2 and #15 would be resolved by #17 when it is reviewed
    • more input in #18 would also be nice to have

    Those things aside, do we want to do anything else for v1.3.0?

    opened by acln0 11
  • rework tests from gocheck to stdlib testing

    rework tests from gocheck to stdlib testing

    Use the standard library testing package instead of gocheck. Switch from multiple assertions to table-driven tests where appropriate.

    Update fuzz testing support: add code to generate a diverse corpus based on existing parser tests, add instructions on how to run the fuzzer, check in the existing corpus.

    opened by acln0 11
  • initial implementation of UUIDv6 and UUIDv7 based on RFC Draft Rev 2

    initial implementation of UUIDv6 and UUIDv7 based on RFC Draft Rev 2

    There is currently an RFC draft in progress[1] to add three new UUID formats, versions 6, 7, and 8, that change the internal data format so that the generated UUIDs are k-sortable. Version 8 is a special UUID format designed for future implementations or extensions, and as a result isn't implemented here.

    Because this impelmentation is based on a draft RFC, they may be subject to change in later revisions. As such, these new functions/methods include a comment indicating they do not yet fall under the API compatibility guarantee of the project, and changes to meet new revisions to the spec will be done in minor releases.

    [1] https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-02

    opened by theckman 8
  • unify import paths under /v4

    unify import paths under /v4

    Create a new /v4 directory, containing a copy of the existing code, allowing the package to move forward and be consumed by all users under a unified import path: github.com/gofrs/uuid/v4.

    Remove go.mod file from the top level directory and add it to the v4 directory. Update v3 to v4 in go.mod.

    Update documentation to reflect the change: Recommend v4.0.0+ as the go-to version for new users and existing modules users. Recommend v2.1.0 under github.com/gofrs/uuid as the go-to version for users looking for a replacement for satori/go.uuid at v1.2.0. Document the two different import paths and their behavior.

    Fixes #61.

    opened by acln0 8
  • Outstanding open issues / PRs in satori/go.uuid

    Outstanding open issues / PRs in satori/go.uuid

    We should take a look at the open issues and pending PRs in https://github.com/satori/go.uuid and see if which ones would be worth tackling / adopting.

    https://github.com/satori/go.uuid/pull/44 was brought up, which I think is a good start.

    Please comment with other issues or PRs if you think they'd be worth doing.

    input wanted 
    opened by acln0 8
  • Generator options

    Generator options

    Hi, I had to generate UUIDv6 with custom timestamps, so I added generator options to be able to change the epoch function. I'm creating this PR in case this is something that others might need or find useful.

    Bye, Matija

    opened by mlesar 0
  • Proposal: to release as a Go Module, archive repo and fork to github.com/gofrs/uuid.go@v0.4.2

    Proposal: to release as a Go Module, archive repo and fork to github.com/gofrs/[email protected]

    I floated this idea very roughly in the #gofrs Slack channel, and it's to effectively rename this repository to avoid the Semantic Import Versioning (SIV) component of Go Modules

    Context

    When this repository was forked from github.com/sator/go.uuid, we chose to keep the same versioning scheme as the original project to help the migration be easier for folks. We did not need to consider Go Modules at the time, and so it was easy to start the project at a major version higher than the original project and assume it was low cost to do a major version increase as necessary.

    Unfortunately, Go Modules has changed the situation, and so with hindsight it would have been better to not follow the versioning of the original project and to instead release as a v0.x version.

    Proposal

    We would create a new repository, github.com/gofrs/uuid.go, and push the master branch of this repository to that one. We would not push any of the tags from this repo there. We'd then create a new tag, v0.4.2, at the same commit† as v4.2.0 of this repo. We would then update the README of this repo to point there, and archive the project. Any new development would happen there on v0.

    † same commit + addition of go.mod file / any updates for the rename

    opened by theckman 5
  • improve performance and reduce allocations of UUID methods

    improve performance and reduce allocations of UUID methods

    This commit improves the performance and reduces the number of allocs of most UUID methods and adds a new UUID.Parse() method for parsing string encoded UUIDs.

    Parsing string encoded UUIDs is now 2x faster and no longer allocates. The NullUUID MarshalJSON() and UnmarshalJSON() methods have also been improved and no longer call out to json.Unmarshal. The UUID.Format method has been improved for common cases.

    Benchmark results:

    goos: linux
    goarch: amd64
    pkg: github.com/gofrs/uuid
    cpu: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
    
    name                        old time/op    new time/op    delta
    UnmarshalText/canonical-16    47.7ns ± 0%    22.3ns ± 0%   -53.26%  (p=0.000 n=8+10)
    UnmarshalText/urn-16          47.8ns ± 1%    22.3ns ± 0%   -53.32%  (p=0.000 n=10+10)
    UnmarshalText/braced-16       47.8ns ± 1%    22.3ns ± 0%   -53.34%  (p=0.000 n=9+9)
    ParseV4-16                    86.5ns ±10%    22.6ns ± 0%   -73.85%  (p=0.000 n=9+8)
    NullMarshalJSON/Valid-16       308ns ±21%      72ns ±12%   -76.71%  (p=0.000 n=10+10)
    NullMarshalJSON/Invalid-16    41.8ns ± 2%     1.4ns ± 0%   -96.59%  (p=0.000 n=10+8)
    Format/s-16                    151ns ± 3%     143ns ± 7%    -5.18%  (p=0.003 n=10+10)
    Format/S-16                    305ns ± 2%     161ns ± 2%   -47.38%  (p=0.000 n=10+9)
    Format/q-16                    217ns ±12%     144ns ± 6%   -33.52%  (p=0.000 n=10+10)
    Format/x-16                    170ns ±13%     123ns ± 1%   -27.95%  (p=0.000 n=10+10)
    Format/X-16                    324ns ±11%     148ns ± 1%   -54.15%  (p=0.000 n=10+10)
    Format/v-16                    156ns ± 4%     142ns ± 5%    -8.68%  (p=0.000 n=10+10)
    Format/+v-16                   155ns ± 3%     142ns ± 6%    -8.67%  (p=0.000 n=10+10)
    Format/#v-16                   894ns ± 1%     847ns ± 1%    -5.22%  (p=0.000 n=10+9)
    String-16                     70.1ns ±36%    70.4ns ±29%      ~     (p=0.971 n=10+10)
    FromBytes-16                  1.81ns ± 0%    1.81ns ± 0%    -0.15%  (p=0.010 n=8+9)
    FromString/canonical-16       94.3ns ±20%    23.3ns ± 1%   -75.25%  (p=0.000 n=10+10)
    FromString/urn-16             93.7ns ±11%    23.8ns ± 1%   -74.66%  (p=0.000 n=10+8)
    FromString/braced-16          87.1ns ± 5%    23.5ns ± 1%   -73.03%  (p=0.000 n=9+10)
    MarshalBinary-16              0.20ns ± 3%    0.20ns ± 1%      ~     (p=0.922 n=10+9)
    MarshalText-16                 115ns ±25%      22ns ± 1%   -80.66%  (p=0.000 n=10+10)
    
    name                        old alloc/op   new alloc/op   delta
    UnmarshalText/canonical-16     0.00B          0.00B           ~     (all equal)
    UnmarshalText/urn-16           0.00B          0.00B           ~     (all equal)
    UnmarshalText/braced-16        0.00B          0.00B           ~     (all equal)
    ParseV4-16                     48.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)
    NullMarshalJSON/Valid-16        160B ± 0%       48B ± 0%   -70.00%  (p=0.000 n=10+10)
    NullMarshalJSON/Invalid-16     8.00B ± 0%     0.00B       -100.00%  (p=0.000 n=10+10)
    Format/s-16                    48.0B ± 0%     48.0B ± 0%      ~     (all equal)
    Format/S-16                    96.0B ± 0%     48.0B ± 0%   -50.00%  (p=0.000 n=10+10)
    Format/q-16                    96.0B ± 0%     48.0B ± 0%   -50.00%  (p=0.000 n=10+10)
    Format/x-16                    64.0B ± 0%     32.0B ± 0%   -50.00%  (p=0.000 n=10+10)
    Format/X-16                     112B ± 0%       32B ± 0%   -71.43%  (p=0.000 n=10+10)
    Format/v-16                    48.0B ± 0%     48.0B ± 0%      ~     (all equal)
    Format/+v-16                   48.0B ± 0%     48.0B ± 0%      ~     (all equal)
    Format/#v-16                    128B ± 0%       16B ± 0%   -87.50%  (p=0.000 n=10+10)
    String-16                      48.0B ± 0%     48.0B ± 0%      ~     (all equal)
    FromBytes-16                   0.00B          0.00B           ~     (all equal)
    FromString/canonical-16        48.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)
    FromString/urn-16              48.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)
    FromString/braced-16           48.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)
    MarshalBinary-16               0.00B          0.00B           ~     (all equal)
    MarshalText-16                 96.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)
    
    name                        old allocs/op  new allocs/op  delta
    UnmarshalText/canonical-16      0.00           0.00           ~     (all equal)
    UnmarshalText/urn-16            0.00           0.00           ~     (all equal)
    UnmarshalText/braced-16         0.00           0.00           ~     (all equal)
    ParseV4-16                      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
    NullMarshalJSON/Valid-16        4.00 ± 0%      1.00 ± 0%   -75.00%  (p=0.000 n=10+10)
    NullMarshalJSON/Invalid-16      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
    Format/s-16                     1.00 ± 0%      1.00 ± 0%      ~     (all equal)
    Format/S-16                     2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=10+10)
    Format/q-16                     2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=10+10)
    Format/x-16                     2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=10+10)
    Format/X-16                     3.00 ± 0%      1.00 ± 0%   -66.67%  (p=0.000 n=10+10)
    Format/v-16                     1.00 ± 0%      1.00 ± 0%      ~     (all equal)
    Format/+v-16                    1.00 ± 0%      1.00 ± 0%      ~     (all equal)
    Format/#v-16                    2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=10+10)
    String-16                       1.00 ± 0%      1.00 ± 0%      ~     (all equal)
    FromBytes-16                    0.00           0.00           ~     (all equal)
    FromString/canonical-16         1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
    FromString/urn-16               1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
    FromString/braced-16            1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
    MarshalBinary-16                0.00           0.00           ~     (all equal)
    MarshalText-16                  2.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
    
    opened by charlievieth 6
  • Support for Go 1.13 Error Wrapping

    Support for Go 1.13 Error Wrapping

    Hi

    I was wondering if you had any interest in support for go1.13 error wrapping? For example:

    const (
    	ErrIncorrectLength Error = iota + 1
    	// Other sentinel error types here
    )
    
    type Error int
    
    func (e Error) Error() string {
    	switch e {
    	case ErrIncorrectLength:
    		return "incorrect length"
    	// Other error strings here
    	default:
    		return "unknown error"
    	}
    }
    
    func (u *UUID) UnmarshalText(text []byte) error {
    	switch len(text) {
    	// Previous switch conditions
    	default:
    		return fmt.Errorf("uuid: %w %d in string %q", ErrIncorrectLength, len(text), text)
    	}
    }
    

    This would allow for the usage of errors.Is() and errors.As(), useful for testing or performing other conditional logic based on the type of error, for example:

    id, err := uuid.FromString("foo")
    if err != nil {
    	if errors.Is(err, uuid.ErrIncorrectLength) {
    		// some bespoke logic
    	}
    }
    

    If you approve I'd be more than happy to open a PR with the implementation detail.If backwards compatibility is a concern we can probably get around it with build tags.

    Demo over on the playground: https://play.golang.org/p/H5teBSdvfct

    opened by krak3n 8
  • Ability to encode specific timestamp into a V1 UUID

    Ability to encode specific timestamp into a V1 UUID

    Hi,

    I have a need to encode a specific timestamp (instead of time.Now()) into a V1 UUID. There doesn't seem to be a way to do that. Before I start coding the change for that, I'm checking to see if this is something that is generally useful or if I should just maintain my own code to do this.

    Thoughts?

    opened by rkuris 1
Releases(v4.3.1)
  • v4.3.1(Oct 31, 2022)

  • v4.3.0(Sep 9, 2022)

    • Update UUIDv7 to conform with RFC Draft Rev 3 by @convto (Breaking change to experimental feature)
    • Update unit test coverage to be 100% by @theckman, and @cameracker

    Full Changelog: v4.2.0...v4.3.0

    Source code(tar.gz)
    Source code(zip)
  • v4.2.0(Nov 26, 2021)

  • v4.1.0(Oct 16, 2021)

    Changes

    • initial implementation of UUIDv6 and UUIDv7 based on RFC Draft Rev 2 by @theckman in https://github.com/gofrs/uuid/pull/93

    Full Changelog: https://github.com/gofrs/uuid/compare/v4.0.0...v4.1.0

    Source code(tar.gz)
    Source code(zip)
  • v4.0.0(Dec 30, 2020)

    • This release removes support for UUIDV2. UUID V2 is underspecified and unsafe for users expecting uniqueness - the time dependence frequently produces duplicate identifiers and V2 is dependent on *nix only time features. UUID V2 is especially weak on Windows operating systems.

    We recommend that all users of the library either upgrade to this version, or at least consider no longer relying on UUID V2 in their applications.

    Source code(tar.gz)
    Source code(zip)
  • v3.3.0(May 5, 2020)

    • the UUID type now satisfied fmt.Formatter; see the .Format() method docs for more info. Contributed by Dylan Bourque (@dylan-bourque) in #72.
    • Codec related error messages have been adjusted to improve clarity and consistency with error message standards. Contributed by Josh Leverette (@coder543 ) in #78.
    Source code(tar.gz)
    Source code(zip)
  • v3.4.0(Dec 30, 2020)

    Note: This release is identical to v3.3.0 and was created by mistake. It is safe to use either.

    • the UUID type now satisfied fmt.Formatter; see the .Format() method docs for more info. Contributed by Dylan Bourque (@dylan-bourque) in #72.
    • Codec related error messages have been adjusted to improve clarity and consistency with error message standards. Contributed by Josh Leverette (@coder543 ) in #78.
    Source code(tar.gz)
    Source code(zip)
  • v3.2.0(Jan 11, 2019)

    • Remove support for the experimental Go Modules feature due to issues supporting both dep and modules, amongst other concerns.

    Please see #61, #66, and #67 for more info.

    Source code(tar.gz)
    Source code(zip)
  • v3.1.2(Oct 30, 2018)

    This release improves the interoperability of package uuid with ORMs such as gorm, per PR #58. Thanks to Jun Jie Nan (@nanjj) for the contribution.

    Source code(tar.gz)
    Source code(zip)
  • v3.1.1(Sep 1, 2018)

  • v3.1.0(Aug 22, 2018)

    This release includes new functionality (PR #31) to help consumers extract a time.Time value out of a Version 1 UUID.

    UUIDs have their own internal timestamp, which is a counter of 100ns increments since the start of the Gregorian Calendar (00:00:00 UTC on 15 Oct, 1582). To represent that a new Timestamp type was added, with a Time() method used to convert the timestamp value to a time.Time value.

    To extract the timestamp from a Version 1 UUID, a new package function (TimestampFromV1) was added to extract a Timestamp out of a UUID. If it's not a V1 UUID it returns an error.

    Big thanks to Ron Kuris (@rkuris) for this contribution!

    Source code(tar.gz)
    Source code(zip)
  • v3.0.0(Aug 2, 2018)

    v3.0.0 denotes the first major change by The Gofrs, and encompasses feature requests / PRs that had been opened against the original project. This version includes the following breaking changes:

    • update the sql.NullUUID type to support both the json.Marshaler and json.Unmarshaler interfaces, which I'll provide more details on later. (#38)
    • remove the Equal function from the package, as the UUID type is an array type and so you can use == directly for comparisons. (#36 #39)

    This version also exposes the internal UUID generator, with constructors, so that consumers can provide their own HWAddrFunc to get the hardware address of the node. This can be used by consumers who want to randomize the MAC address in a V1 UUID. (#42)

    In regards to the JSON change, the sql.NullUUID type is one that's used with the database/sql package to support columns that can contain UUIDs or a NULL value. This means it's a struct with a UUID and Valid field, so previously a sql.NullUUID would marshal to JSON like so:

    {
      "uuid": {
        "uuid": "3bdef553-9b6a-4620-8a5f-b94bf22a2520",
        "valid": true
      }
    }
    

    By implementing the right interfaces from the JSON package, it'll now marshal like so:

    {
      "uuid": "3bdef553-9b6a-4620-8a5f-b94bf22a2520"
    }
    
    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Jul 21, 2018)

    Version 2.1.0 is functionally equivalent to 2.0.1. It introduces a documentation change to indicate that the package's Equal function is deprecated in favor of just comparing two UUID values to one another using ==. This change was made in #36.

    We plan on removing this function in v3.0.0.

    Source code(tar.gz)
    Source code(zip)
  • v2.0.1(Jul 19, 2018)

    This change includes two small fixes to the Equal package function both done within #34:

    • update the documentation / function arguments to be more clear
    • compare the UUID values to each other directly, instead of converting to slices and then comparing using bytes.Equal
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Jul 18, 2018)

    This is first release of this package as github.com/gofrs/uuid, after having been forked from github.com/satori/go.uuid at 36e9d2ebbde5e3f13ab2e25625fd453271d6522e.

    The reason behind the decision to fork was due to lack of engagement from the original author, when there were fatal bugs present. The intent is to keep up the support of this package by not having the burden rest on one individual.

    This is a major version bump as the forked project introduced breaking changes (0ef6afb2f6cd) after v1.2.0 that were never captured in a release. These changes were the addition of error return values of some of the UUID generation methods.

    A major bug was fixed (#7) that would have resulted in UUIDs that weren't so unique. The original bug report is here: https://github.com/satori/go.uuid/issues/73

    In addition to that, some small API enhancements/fixes were made:

    • export the default generator used by the package-level functions as DefaultGenerator (#9)
    • update code to work as documented by supporting braced hashlike UUIDs in the FromString callpath (#14)
    • remove named return values from the function definitions (#25)
    • linter caught an issue where an error value was shadowed (#10)

    While they have no impact on the functional usage of this package, the following improvements were also made in areas ranging from docs to testing:

    • set up Travis CI for testing and coveralls for coverage (#6)
    • we stopped testing against older versions of Go, to support subtests (#21)
    • tests no longer use gocheck and are stdlib only (#17)
    • added support for fuzz testing (#5 #17)
    • enhanced tests to improve coverage (catch issues) (#3 #24)
    • fixed linter issues around variable names (#10)
    • updated docs to be more clear and correct (#8 #12 #16 #28 #29)
    • recommend that consumers only use 2.0.0+ at this point (#30)

    This release wouldn't be anywhere near as polished if it weren't for the help of a few people in the Go community. Alphabetized by their GitHub handles:

    • Andrei Tudor Călin (@acln0)
    • Jamie Stackhouse (@itsjamie)
    • Jaden Weiss (@jadr2ddude)
    • Trevor Starick (@trevorstarick)
    • Ivan Kurnosov (@zerkms)

    There are also a few people who provided input in the #gofrs Slack channel or on issues / PRs:

    • Cameron Ackerman (@CameronAckermanSEL)
    • Timur Makarchuk (@makarchuk)
    Source code(tar.gz)
    Source code(zip)
Owner
The Go Commune
We are the Gofrs: a community-driven effort to provide maintainers for valuable projects, as well as for building projects that benefit the larger Go community
The Go Commune
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 Nov 19, 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
An extremely fast UUID alternative written in golang

Overview WUID is a globally unique number generator, while it is NOT a UUID implementation. WUID is 10-135 times faster than UUID and 4600 times faste

Edwin 478 Nov 16, 2022
An extremely fast UUID alternative written in golang

Overview WUID is a globally unique number generator, while it is NOT a UUID implementation. WUID is 10-135 times faster than UUID and 4600 times faste

Edwin 11 May 10, 2021
A lightweight UUID implementation

uuid uuid is a lightweight implementation for Univerally unique identifier. Usage var id UUID = uuid.Rand() fmt.Println(id.Hex()) fmt.Println(id.Raw()

Steven Luu 53 Feb 25, 2020
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
Generate UUID for script's sql

Generate UUID for script's sql Instale o go em sua maquina https://golang.org/doc/install Baixe as seguintes dependecias go get github.com/satori/go.u

Leandro Costa 1 Oct 26, 2021
Alternative random id generation to uuid

randid import "go.withmatt.com/randid" id := randid.New().String() randid's goals are simple: a smaller, more compact, faster version of uuid4. I don

Matt Robenolt 7 Nov 16, 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 35 Oct 7, 2022
Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.

uuid 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 g

Google 4k Nov 21, 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 2.2k Nov 22, 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
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
Terraform Provider for Satori

Terraform Provider for Satori First time setup: make init Run the following command to build the provider make build Generate/update documentation Do

Satori Cyber 18 Nov 2, 2022
An AMQP 0-9-1 Go client maintained by the RabbitMQ team. Originally by @streadway: `streadway/amqp`

Go RabbitMQ Client Library This is a Go AMQP 0.9.1 client maintained by the RabbitMQ core team. It was originally developed by Sean Treadway. Differen

RabbitMQ 613 Nov 18, 2022
A highly-scalable, entity-resolution technology that was originally developed to connect internal data together

TiloRes CLI What is TiloRes? TiloRes is a highly-scalable, “entity-resolution” technology that was originally developed to connect internal data toget

Tilo Tech GmbH 4 Jun 17, 2022
ECIES implementation forked of the `crypto/ecies` package from Ethereum

# NOTE This implementation is direct fork of Kylom's implementation. I claim no authorship over this code apart from some minor modifications. Please

Stichting Nuts 0 Dec 7, 2021
LINE Financial Blockchain forked from gaia

LFB(LINE Financial Blockchain) This repository hosts LFB(LINE Financial Blockchain). This repository is forked from gaia at 2021-03-15. LFB is a mainn

LINE 31 Oct 30, 2022
A fork on miekg/dns (since I've already forked zmap/dns)

Alternative (more granular) approach to a DNS library Less is more. Complete and usable DNS library. All Resource Records are supported, including the

null 0 Jan 19, 2022
Forked Version of Miekg's DNS library that recycles UDP sockets

Alternative (more granular) approach to a DNS library Less is more. Complete and usable DNS library. All Resource Records are supported, including the

null 0 Jan 20, 2022