forked from golang-plus/uuid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.go
51 lines (46 loc) · 1.63 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package uuid
import (
"github.com/golang-plus/uuid/internal"
)
// Version represents the version of UUID. See page 7 in RFC 4122.
type Version byte
// Versions.
const (
// VersionUnknown represents unknown version.
VersionUnknown = Version(internal.VersionUnknown)
// VersionTimeBased represents the time-based version (Version 1).
VersionTimeBased = Version(internal.VersionTimeBased)
// VersionDCESecurity represents the DCE security version, with embedded POSIX UIDs (Version 2).
VersionDCESecurity = Version(internal.VersionDCESecurity)
// VersionNameBasedMD5 represents the name-based version that uses MD5 hashing (Version 3).
VersionNameBasedMD5 = Version(internal.VersionNameBasedMD5)
// VersionRandom represents the randomly or pseudo-randomly generated version (Version 4).
VersionRandom = Version(internal.VersionRandom)
// VersionNameBasedSHA1 represents the name-based version that uses SHA-1 hashing (Version 5).
VersionNameBasedSHA1 = Version(internal.VersionNameBasedSHA1)
)
// Short names of versions.
const (
V1 = VersionTimeBased
V2 = VersionDCESecurity
V3 = VersionNameBasedMD5
V4 = VersionRandom
V5 = VersionNameBasedSHA1
)
// String returns English description of Version.
func (v Version) String() string {
switch v {
case VersionTimeBased:
return "Version 1: Time-Based"
case VersionDCESecurity:
return "Version 2: DCE Security With Embedded POSIX UIDs"
case VersionNameBasedMD5:
return "Version 3: Name-Based (MD5)"
case VersionRandom:
return "Version 4: Randomly OR Pseudo-Randomly Generated"
case VersionNameBasedSHA1:
return "Version 5: Name-Based (SHA-1)"
default:
return "Version: Unknwon"
}
}