UUID
Allison Piovani
Posted on July 17, 2022
Universally Unique Identifier or GUID Globally Unique Identifier which in practice it's the same thing.
It's composed by 128 Bits represented by 32 digits Hexadecimal, divided by 5 groups separeted by "-" with struct: 8-4-4-4-12.
The goal identify unique information in the System, whithout a central chord.
Exist 5 versions, the first digit from third batch, is separated to identify the version of UUID.
Versions
v1
Uses timestemp to generate the UUID, also can use NodeID which is an identifier, usually for that MAC of the computer, or URL or prefixed data key.v2
Very similiar to v1, but the use of NodeID is mandatory to present a security group, this group may be related to entities or some context of the application. But veru little used.v3 and v5
It also use NodeIDas prefix. In v3 is used an MD5 hash key, while in v5 a has key of the SHA-1 algorithm is used, this second being more advised for development.v4
It is the most used version, in this case all characters are randomly generated.
Benefits
It's also a form of information security, the ID format increment informs how many users there may be on the plaform, important information for competitiros;
Greater security if you don't have Authorization control in the application.
Disadvantages
Makes debugging records more complex;
Increase in the cost of storage, storing in string format, char(32) can make the performance of queries quite heavy, a solution is to store in binaries;
Must have a position rule, since the collision is possible.
Go
Inside Go we have a lot of packages that press UUID, but in this demo we will use the official google package Package, in addition to supporting all of the above versions. The project link is here: Project
Posted on July 17, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.