Comments (10)
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 needMust*
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 thatNew()
is an alias foruuid.Must(uuid.NewRandom())
. I don't really know under what conditionsrand.Reader.Read()
returns an error but I am a fan of symmetry.
from uuid.
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.
Sure thing, #3
from uuid.
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.
@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.
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.
I have push fixes for the naming issues, including a few others with non-exported names.
from uuid.
Indeed that is my mistake about the Nil UUID. I didn't realize that name was part of the specification.
from uuid.
Could there be a function to compare the equality of UUIDs?
from uuid.
There is no need for a function, arrays (which is what the UUID type is) are directly comparable.
from uuid.
Related Issues (20)
- Equals method HOT 1
- Reference implementaiton for UUID v8 HOT 2
- Is there a method to generate empty UUID v4? HOT 2
- UUID with repeat ending HOT 2
- NullUUID Scan method returns valid true on empty string HOT 2
- [Documentation] uuid.Nil is not documented properly
- `IsZero()` and `ToNullUUID` Helper Functions HOT 1
- panic: uuid: Parse(): invalid UUID length: 0 HOT 1
- Should uuid.Nil marshal to null instead of all zeroes HOT 3
- Make uuid.Nil and other values as a constant HOT 1
- Cannot get the package, connection refused
- uuid.Parse allows invalid UUID's HOT 2
- recommended to add uuid v6 and v7 support HOT 1
- Validate UUID without creating UUID (and underlying byte array)
- Limit permissions for github workflows
- uuid.Parse Function Does Not Handle Leading/Trailing Spaces in UUIDs
- Monotonicity in UUIDv7 HOT 2
- proposal: add func uuid.Compare(a, b UUID) int
- Incorrect uuidv6 implementation HOT 1
- not able to install uuid package HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uuid.