Git Product home page Git Product logo

Comments (10)

bmatsuo avatar bmatsuo commented on May 6, 2024

I think the text/template style of Must would make more sense in this package.. I made this comment in pborman/uuid#3 (comment) but I don't think it was ever addressed or responded to. It's fine if you disagree but I want to make sure you did consider it. Here's the excerpt my original comment

  • Consider a function func Must(uuid UUID, err error) UUID so that you don't need Must* Variants for each type of UUID.
u := uuid.Must(uuid.NewUUID())
// ...
  • I think you could probably have a NewRandom function that returns an error. Then you can document that New() is an alias for uuid.Must(uuid.NewRandom()). I don't really know under what conditions rand.Reader.Read() returns an error but I am a fan of symmetry.

from uuid.

pborman avatar pborman commented on May 6, 2024

Thank you for bringing that up again. Yes, it sort of go lost in the mix. I think it makes a lot of sense. Would you like to create a pull request to do this? The existing MustParse can just go away then. I would be happy to do it, but it would be nice for the history to show it came from you.

from uuid.

bmatsuo avatar bmatsuo commented on May 6, 2024

Sure thing, #3

from uuid.

bmatsuo avatar bmatsuo commented on May 6, 2024

During those changes I noticed that the global variables don't seem to conform to Go best practices (e.g. code review wiki). In addition to use of underscores and CAPS (i.e. NIL) I think the capitalization of NameSpace is incorrect because namespace is a single word.

It seems like the global variables should have the following names

var (
    NamespaceDNS  = ...
    NamespaceURL  = ...
    NamespaceOID  = ...
    NamespaceX500 = ...
    Nil           UUID
)

from uuid.

bmatsuo avatar bmatsuo commented on May 6, 2024

@pborman any thoughts on the proposed name changes above? I've took a real pass through the API and came up with a couple other suggestions.

  • Instead of NIL/Nil, which is intentionally a misnomer, perhaps Zero or Z could be used instead. Personally I think the variable could simply be removed completely, but I don't think it's really a big deal..
  • The method UUID.Id() should be UUID.ID(). In the context of NodeID capital letters are used consistently. The Id() method seems to be the only inconsistent usage.

from uuid.

pborman avatar pborman commented on May 6, 2024

The name Nil is correct. From RFC 4122:

4.1.7. Nil UUID
The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.

The other name changes look reasonable.

from uuid.

pborman avatar pborman commented on May 6, 2024

I have push fixes for the naming issues, including a few others with non-exported names.

from uuid.

bmatsuo avatar bmatsuo commented on May 6, 2024

Indeed that is my mistake about the Nil UUID. I didn't realize that name was part of the specification.

from uuid.

meyerzinn avatar meyerzinn commented on May 6, 2024

Could there be a function to compare the equality of UUIDs?

from uuid.

pborman avatar pborman commented on May 6, 2024

There is no need for a function, arrays (which is what the UUID type is) are directly comparable.

from uuid.

Related Issues (20)

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.