https://github.com/daanv2/go-uuid
A library that provides a way to handle, and generate UUIDs. Complies with the RFC 4122 standard.
https://github.com/daanv2/go-uuid
go golang rfc-4122 uuid
Last synced: 5 months ago
JSON representation
A library that provides a way to handle, and generate UUIDs. Complies with the RFC 4122 standard.
- Host: GitHub
- URL: https://github.com/daanv2/go-uuid
- Owner: DaanV2
- License: mit
- Created: 2024-01-28T17:07:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-17T17:54:51.000Z (about 2 years ago)
- Last Synced: 2025-01-08T18:54:32.926Z (over 1 year ago)
- Topics: go, golang, rfc-4122, uuid
- Language: Go
- Homepage: https://pkg.go.dev/github.com/DaanV2/go-uuid
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go UUID
[](https://github.com/DaanV2/go-uuid/actions/workflows/pipeline.yaml)
A library that provides a way to handle, and generate UUIDs. Complies with RFC 4122 and RFC 9562 standards. Based on the code I wrote for [.dotnet - DaanV2.UUID.Net](https://github.com/DaanV2/DaanV2.UUID.Net)
```go
import "github.com/DaanV2/go-uuid"
u := uuid.New()
u := uuid.NewString()
//Specific version
u := uuid.V4.New()
u := uuid.V4.NewString()
// Hash-based UUIDs
u := uuid.V5.New([]byte("Some data"))
u := uuid.V3.New([]byte("Some data"))
// Time-based UUIDs (RFC 9562)
u, err := uuid.V6.New() // Reordered timestamp UUID (better for databases)
u := uuid.V7.New() // Unix timestamp-based UUID (time-ordered)
// Custom/vendor-specific UUID (RFC 9562)
u := uuid.V8.New() // Random
u := uuid.V8.From([]byte("custom")) // From custom data
// Batch generation
u := uuid.V4.NewBatch(10)
```
## Supported UUID Versions
- **V1**: Timestamp and MAC address-based UUID (RFC 4122)
- **V3**: MD5 hash-based UUID (RFC 4122)
- **V4**: Random UUID (RFC 4122)
- **V5**: SHA-1 hash-based UUID (RFC 4122)
- **V6**: Reordered timestamp UUID - better database indexing than V1 (RFC 9562)
- **V7**: Unix timestamp-based UUID with random data - time-ordered (RFC 9562)
- **V8**: Custom/vendor-specific UUID format (RFC 9562)
## Install
```bash
go get github.com/DaanV2/go-uuid
```