Giter Club home page Giter Club logo

uuid's People

Contributors

bmatsuo avatar bormanp avatar cd1 avatar cez81 avatar creack avatar dansouza avatar dmitris avatar dsymonds avatar elliott5 avatar flimzy avatar jboverfelt avatar jcbwlkr avatar joe2far avatar kishorkunal-raj avatar kristoiv avatar kveselkov avatar leofantast avatar pborman avatar petergloor avatar shawnps avatar theory avatar wallclockbuilder 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uuid's Issues

Error trying to install

$ go get github.com/pborman/uuid

can't load package: package github.com/pborman/uuid: no buildable Go source files in MY_WORSKPACE/src/github.com/pborman/uuid

BUG from source

go get -t -v -d ./...
CC=cc go install -v -tags "libsqlite3" ./...
github.com/pborman/uuid
github.com/CanonicalLtd/go-dqlite/internal/bindings
github.com/CanonicalLtd/go-dqlite/internal/trace
github.com/armon/go-metrics

github.com/pborman/uuid

../../pborman/uuid/time.go:15: syntax error: unexpected = in type declaration
github.com/miekg/dns

github.com/CanonicalLtd/go-dqlite/internal/trace

../../CanonicalLtd/go-dqlite/internal/trace/set.go:112: undefined: sort.Slice

github.com/armon/go-metrics

../../armon/go-metrics/inmem_endpoint.go:72: undefined: sort.Slice
../../armon/go-metrics/inmem_endpoint.go:86: undefined: sort.Slice
../../armon/go-metrics/inmem_endpoint.go:113: undefined: sort.Slice

github.com/miekg/dns

../../miekg/dns/msg_helpers.go:144: base32.HexEncoding.WithPadding undefined (type *base32.Encoding has no field or method WithPadding)
../../miekg/dns/msg_helpers.go:144: undefined: base32.NoPadding

github.com/CanonicalLtd/go-dqlite/internal/bindings

../../CanonicalLtd/go-dqlite/internal/bindings/testing.go:13: t.Helper undefined (type *testing.T has no field or method Helper)
../../CanonicalLtd/go-dqlite/internal/bindings/server.go:26: constant -8786437285571510299 overflows uint64
Makefile:18: ошибка выполнения рецепта для цели «default»
make: *** [default] Ошибка 2

Invalid UUID format with Postgres

I get a "Scan: invalid UUID format" when using with PostgreSQL. Seems that it parses ok but, when checking the variant of the UUID, if the length is more than 16 bytes then it's considered invalid. However, Postgres returns a UUID of length 36 (32 hex + 4 dashes) with uuid_generate_v4() function from uuid-ossp extension in accordance with Section 3 of RFC4122.

Make UUID an array type

This is more of a question than a bug, but why not make the UUID a `[16]byte` 
type, instead of the slice, `[]byte`?

Alternatively, to make it backwards-compatible, it could be a pointer type, 
`*[16]byte`.

Original issue reported on code.google.com by attilaolah on 16 Dec 2014 at 2:58

Contributors need to sign the CLA

I was informed by our legal counsel that, just like the Go project, contributors to the uuid package must sign the Google CLA. It was my mistake for not requesting this before accepting any pull requests. I am sorry about that. Basically, the CLA gives Google the right to redistribute the code you have contributed to any Google open source project (because I work for Google, my projects automatically fall under this category). On the plus side, the CLA specifically states your contribution is AS IS and you are under no obligation to support the code :-)

The CLA is at https://cla.developers.google.com/clas

Please let me know when you have signed the CLA. Thank you for your understanding.

-Paul

Contributors: @bmatsuo @shawnps @theory @jboverfelt @cd1 @dansouza @wallclockbuilder

uuid_test.go:365: NodeInterface "user" after SetInterface

+ GOPATH=/builddir/build/BUILD/uuid-c65b2f87fee37d1c7854c9164a450713c28d50cd/_build:/usr/share/gocode
+ go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro  '\'''
--- FAIL: TestNode (0.00s)
        uuid_test.go:291: NodeInterface returned an empty string
--- FAIL: TestNodeID (0.00s)
        uuid_test.go:365: NodeInterface "user" after SetInterface
FAIL
exit status 1
FAIL    gopkg.in/pborman/uuid.v1        0.007s

Unsafe use of clock_seq

In GetTime, the clock_seq variable is updated inside a mutex. However, when 
NewUUID accesses the clock_seq, it is outside of this lock. As a result a race 
condition exists where multiple threads will update the clock_seq in an atomic 
fashion, but each of them will generate a UUID with the same value.

I have included a patch file which implements a possible fix.

I have also attached test.go, which illustrates the problem. The following 
results were produced on an 8-core 4Ghz machine with 32gb of ram:

2014/12/01 04:01:04 Creating Channels
2014/12/01 04:01:04 Starting Threads
2014/12/01 04:01:04 Wating for Completion
2014/12/01 04:01:06 Processing Data. Execution took: 2.0741186s
2014/12/01 04:01:13 Found duplicate UUID!!!
2014/12/01 04:01:13 Found duplicate UUID!!!
2014/12/01 04:01:16 Found duplicate UUID!!!
2014/12/01 04:01:17 Found duplicate UUID!!!
2014/12/01 04:01:18 Found duplicate UUID!!!
2014/12/01 04:01:18 Found duplicate UUID!!!
2014/12/01 04:01:19 Found duplicate UUID!!!
2014/12/01 04:01:20 Found duplicate UUID!!!
2014/12/01 04:01:22 Found duplicate UUID!!!
2014/12/01 04:01:23 Found duplicate UUID!!!
2014/12/01 04:01:23 Found duplicate UUID!!!
2014/12/01 04:01:26 Found duplicate UUID!!!
2014/12/01 04:01:26 Done.

The following test is after the patch is applied:

2014/12/01 04:01:44 Creating Channels
2014/12/01 04:01:44 Starting Threads
2014/12/01 04:01:44 Wating for Completion
2014/12/01 04:01:46 Processing Data. Execution took: 2.0071148s
2014/12/01 04:02:06 Done.


Original issue reported on code.google.com by [email protected] on 1 Dec 2014 at 9:33

Attachments:

Use pointer Valuer to fix nil pointer issue

type Opportunity struct {
    ID                  *int       `db:"OpportunityId,omitempty"`
    GlobalOpportunityID *uuid.UUID `db:"GlobalOpportunityId,omitempty"`
}

I am using a this struct and when I call database actions I'm running into golang/go#8415 because go is calling Value() even though the pointer is nil. This is something they appear to be fixing in a later version, but their suggestion is to put a Valuer on *UUID instead of UUID. I changed the sql.go Value() method in my vendor folder to use a pointer and the issue went away.

Does this create any problems that I'm missing?

Please tag releases

Please consider assigning version numbers and tagging releases. Tags/releases
are quite useful for downstream package maintainers (in Debian and other distributions) to export source tarballs, automatically track new releases and to declare dependencies between packages. Read more in the Debian Upstream Guide.

Thank you.

Database driver reuses src. []byte causing live UUIDs

Caused by #6 . There is an implementation bug where "src" slice of bytes is returned after casting it to uuid.UUID. Then the database driver (tested with major mysql driver: github.com/go-sql-driver/mysql) reuses the src slice.

New UUID type optimized for DB indexing

I'm considering adding a second type of UUID to the package that, when used with databases (sql.go), makes it easier to work with UUID values as indexed values by observing the best practices described at Storing UUID Values in MySQL Tables when it comes to encoding the UUID into a binary form (for better indexing). Alternatively just the uuid.Parse() and uuid.String() functions could be changed to manipulate the internal binary representation of the uuid, but this might break some cases where people rely on the internal representation to be a standard UUIDv1. I still need to plan the details on how to implement this optimally, but wanted to ask first: would this new type be welcomed into this package?

Ideally this should shit on the DB side of things (with a proper UUID data type, I think pgsql does that) but MySQL/MariaDB/Percona lacks it, so having the client-side do these conversions magically would help by making things work transparently.

Data race

The global nodeID variable is not protected by a mutex, and leads to data races in some cases. Below is the relevant portion of a data race dump from one of my applications.

==================
WARNING: DATA RACE
Read at 0x000000aa5fd0 by goroutine 24:
  gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/pborman/uuid.NewUUID()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/pborman/uuid/version1.go:18 +0x52
  gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/FlashbackSRS/flashback-model.GenerateUser()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/FlashbackSRS/flashback-model/user.go:31 +0x2f
  gitlab.com/FlashbackSRS/flashback-server/models/users.(*Model).createUserByProviderID()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/models/users/users.go:152 +0x18c
  gitlab.com/FlashbackSRS/flashback-server/models/users.TestCreateUserByProviderID.func3.1()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/models/users/users_test.go:349 +0x12c
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:746 +0x16c

Previous write at 0x000000aa5fd0 by goroutine 23:
  gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/pborman/uuid.setNodeInterface()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/pborman/uuid/node.go:102 +0x2c9
  gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/pborman/uuid.SetNodeInterface()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/pborman/uuid/node.go:37 +0x83
  gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/pborman/uuid.NewUUID()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/pborman/uuid/version1.go:19 +0x529
  gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/FlashbackSRS/flashback-model.GenerateUser()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/vendor/github.com/FlashbackSRS/flashback-model/user.go:31 +0x2f
  gitlab.com/FlashbackSRS/flashback-server/models/users.(*Model).createUserByProviderID()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/models/users/users.go:152 +0x18c
  gitlab.com/FlashbackSRS/flashback-server/models/users.TestCreateUserByProviderID.func3.1()
      /go/src/gitlab.com/FlashbackSRS/flashback-server/models/users/users_test.go:349 +0x12c
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:746 +0x16c

go vet error message

code.google.com/p/go-uuid/uuid/uuid.go:116: unreachable code
code.google.com/p/go-uuid/uuid/uuid_test.go:319: no formatting directive in 
Errorf call
code.google.com/p/go-uuid/uuid/uuid_test.go:328: no formatting directive in 
Errorf call
code.google.com/p/go-uuid/uuid/uuid_test.go:331: no formatting directive in 
Errorf call


What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by tailinchu on 27 Dec 2014 at 2:01

Implement the sql.Scanner interface

UUIDs are often used when working with RDBMSes. It would be convenient if the 
sql.Scanner interface from the database/sql package were implemented.

Original issue reported on code.google.com by [email protected] on 13 Apr 2015 at 6:32

Not JSON-compatible

What steps will reproduce the problem?
1. Create a new UUID
2. Marshal said UUID
3. Unmarshal the result of 2 into a new UUID

What is the expected output? What do you see instead?

Both UUIDs should be equal. Instead, step 3 throws an Unmarshal error. 
Marshaling occurs as is typical for byte slices--it is encoded as a string--but 
Unmarshaling cannot unmarshal a string to type UUID.

What version of the product are you using? On what operating system?

This was confirmed in Go 1.2rc3 on the Go playground: 
http://play.golang.org/p/BUo5pw9BAO. It is running against the latest master of 
go-uuid, 7dda39b2e7d5.

Please provide any additional information below.

This should be simple enough to fix: extend the UUID type to implement 
Marshaler and Unmarshaler. I would expect them to call json.Marshal on 
id.String() (where id is a UUID), and json.Unmarshal, followed by Parse() on 
the result.

If this were on Github or something similar, I'd submit a pull request. 
Unfortunately, I'm unsure as to how to do that on Google Code. Instead, I've 
implemented a variation on the Go Playground: 
http://play.golang.org/p/OXjK4Jdd7w

This could be implemented by aliasing the UUID type locally an extending it, 
but that seems like a silly wrapper to maintain, rather than adding two 
functions to go-uuid.

Original issue reported on code.google.com by [email protected] on 17 Apr 2014 at 5:09

"syntax error: unexpected ="

Hallo,

unfortunately I cannot install this:

% go get github.com/pborman/uuid # github.com/pborman/uuid go/src/github.com/pborman/uuid/time.go:15: syntax error: unexpected =

Mebus

Question about repository status

I'm curious about about how this project is related to github.com/google/uuid. It would appear that this is a fork of that project (or vice versa), and pborman seems to be an admin to that repo as well, but I'm not sure if one of these repos should be considered more "official" than the other. Would anyone be able to offer some clarification?

Go 1.15: error messages changed so test is failing

Go 1.15 rc 1 on Fedora Rawhide:

Testing    in: /builddir/build/BUILD/getopt-ee0cd42419d3adee9239dbd1c375717fe482dac7/_build/src
         PATH: /builddir/build/BUILD/getopt-ee0cd42419d3adee9239dbd1c375717fe482dac7/_build/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
       GOPATH: /builddir/build/BUILD/getopt-ee0cd42419d3adee9239dbd1c375717fe482dac7/_build:/usr/share/gocode
  GO111MODULE: off
      command: go test -buildmode pie -compiler gc -ldflags "-X github.com/pborman/getopt/version.commit=ee0cd42419d3adee9239dbd1c375717fe482dac7 -X github.com/pborman/getopt/version=0 -extldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '"
      testing: github.com/pborman/getopt
github.com/pborman/getopt
--- FAIL: TestDuration (0.00s)
    duration_test.go:64: duration_test.go:40: got error "test: time: missing unit in duration \"1\"\nUsage: test [-d value] [--duration value] [parameters ...]\n", want "test: time: missing unit in duration 1\n"
    duration_test.go:64: duration_test.go:46: got error "test: time: invalid duration \"foo\"\nUsage: test [-d value] [--duration value] [parameters ...]\n", want "test: time: invalid duration foo\n"
FAIL
exit status 1
FAIL	github.com/pborman/getopt	0.003s

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.