GithubHelp home page GithubHelp logo

gouuid's Introduction

Pure Go UUID implementation

This package provides immutable UUID structs and the functions NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 and 5 UUIDs as specified in RFC 4122.

Installation

Use the go tool:

$ go get github.com/nu7hatch/gouuid

Usage

See documentation and examples for more information.

Copyright

Copyright (C) 2011 by Krzysztof Kowalik [email protected]. See COPYING file for details.

gouuid's People

Contributors

elimisteve avatar kisielk avatar nu7hatch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gouuid's Issues

Not compliant with RFC4122 spec

The generated variant for nu7hatch uuids does not seem to be compliant with the RFC 4122 spec; this results in all nu7hatch uuids failing any RFC4122-based compliance/validation checks.

Quoting the spec (from https://tools.ietf.org/html/rfc4122#section-4.1.1)

4.1.1.  Variant
...

Msb0  Msb1  Msb2  Description
...
    1     0     x    The variant specified in this document.
...

Note though that the variant of nu7hatch uuids has these MSB bits set to 01, rather than 10; example code:

package main

import (
	"fmt"

	"github.com/nu7hatch/gouuid"
)

func main() {

	// create a new v4 uuid
	v4UUID, err := uuid.NewV4()
	if err != nil {
		panic(err.Error())
	}

	// RFC4122 states the variant format should be MSB0==1 and MSB1==0;
	// https://tools.ietf.org/html/rfc4122#section-4.1.1
	fmt.Printf("%08b\n", v4UUID.Variant())

}

Output:
01000000

Go 1.10: uuid_test.go:50: Errorf format %d has arg err.Error() of wrong type string

179d4d0 does not pass unit tests with Go 1.10

+ GOPATH=/builddir/build/BUILD/gouuid-179d4d0c4d8d407a32af483c2354df1d2c91e6c3/_build:/usr/share/gocode
+ go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro  '\'''
# github.com/nu7hatch/gouuid
./uuid_test.go:50: Errorf format %d has arg err.Error() of wrong type string
./uuid_test.go:98: Errorf format %d has arg err.Error() of wrong type string
FAIL    github.com/nu7hatch/gouuid [build failed]

please tag and version this project

Hello,

Can you please tag and version this project?

I am the Debian Maintainer for gouuid and versioning would help Debian keep up with development.

Valid UUID not parsing correctly

The following UUID has passed several other validations but fails with the gouuid library?

package main

import (
    "fmt"

    "github.com/nu7hatch/gouuid"
)

func main() {
    s := "1c08d1b4-3cd4-698d-e053-0100007f2bc1"
    if _, err := uuid.ParseHex(s); err != nil {
        fmt.Printf("Cannot Parse %+v", err)
    }
}

Bug in doc - byte array missing

small bug in the docs.

       // generating v5 (or v3...)
    u5, _ := uuid.NewV5(uuid.NamespaceURL, "nu7hat.ch")

needs to be

        // generating v5 (or v3...)
    u5, _ := uuid.NewV5(uuid.NamespaceURL,  []byte("nu7hat.ch"))

Go V3 UUIDs do not match Python V3

This is probably not an issue, but I'm trying to understand why this library would differ from the Python library.

Given the following two code segments:

Go::
package main

import "github.com/nu7hatch/gouuid"
import "fmt"

func main() {
c, _ := uuid.ParseHex("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
x, _ := uuid.NewV3(c, []byte("test"))
fmt.Println(x.String())
}

Outputs: 45a113ac-c7f2-30b0-50a5-a399ab912716

Python::
import uuid
c = uuid.UUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
print uuid.uuid3(c, "test")

Outputs: 45a113ac-c7f2-30b0-90a5-a399ab912716

Using Go 1.2 and Python 2.7.2

Note that the 8th byte is different, giving 90a5 instead of 50a5. Looking into this suggests that this library uses a different variant than Python. Was this a conscious decision? Are you following a different standard than them?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.