https://github.com/ashwingopalsamy/uuidcheck
A tiny, zero-dependency Go library that validates UUIDs against standard RFC 4122 formatting, converts UUIDv7() into timestamps by ensuring accuracy and light compute.
https://github.com/ashwingopalsamy/uuidcheck
go good-first-issue good-first-project open-source timestamp uuid
Last synced: 7 months ago
JSON representation
A tiny, zero-dependency Go library that validates UUIDs against standard RFC 4122 formatting, converts UUIDv7() into timestamps by ensuring accuracy and light compute.
- Host: GitHub
- URL: https://github.com/ashwingopalsamy/uuidcheck
- Owner: ashwingopalsamy
- License: mit
- Created: 2024-12-06T11:55:02.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-12-08T04:28:39.000Z (12 months ago)
- Last Synced: 2025-05-07T09:09:34.677Z (7 months ago)
- Topics: go, good-first-issue, good-first-project, open-source, timestamp, uuid
- Language: Go
- Homepage: https://github.com/ashwingopalsamy/uuidcheck
- Size: 21.5 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go-cn - uuidcheck - free Go library that validates UUIDs against standard RFC 4122 formatting, converts UUIDv7() into UTC timestamps. [![godoc][D]](https://godoc.org/github.com/ashwingopalsamy/uuidcheck) (UUID / 实用程序/Miscellaneous)
- awesome-go-plus - uuidcheck - A tiny, dependency-free Go library that validates UUIDs against standard RFC 4122 formatting, converts UUIDv7() into UTC timestamps.  (UUID / Utility/Miscellaneous)
- fucking-awesome-go - uuidcheck - A tiny, dependency-free Go library that validates UUIDs against standard RFC 4122 formatting, converts UUIDv7() into UTC timestamps. (UUID / Utility/Miscellaneous)
- awesome-go - uuidcheck - A tiny, dependency-free Go library that validates UUIDs against standard RFC 4122 formatting, converts UUIDv7() into UTC timestamps. (UUID / Utility/Miscellaneous)
- awesome-go-with-stars - uuidcheck - A tiny, dependency-free Go library that validates UUIDs against standard RFC 4122 formatting, converts UUIDv7() into UTC timestamps. (UUID / Utility/Miscellaneous)
- awesome-go - uuidcheck - A tiny, dependency-free Go library that validates UUIDs against standard RFC 4122 formatting, converts UUIDv7() into UTC timestamps. (UUID / Utility/Miscellaneous)
README
# uuidcheck
[](https://pkg.go.dev/github.com/ashwingopalsamy/uuidcheck)
[](https://github.com/avelino/awesome-go)
[](https://goreportcard.com/report/github.com/ashwingopalsamy/uuidcheck)
[](https://codecov.io/gh/ashwingopalsamy/uuidcheck)
[](LICENSE)
A tiny, zero-dependency Go library that validates UUIDs against standard RFC 4122 formatting, converts UUIDv7() into timestamps by ensuring accuracy and light compute.
**Why?**
Sometimes you just need to know if that string is a proper UUID without dragging in heavy libraries or writing clunky checks. `uuidcheck` does one thing and does it well.
## Features
- **Simple & Light:** No regular expressions, no external dependencies and a single-pass check.
- **Strict RFC 4122 Format:** Ensures correct length, hyphen positions and valid hex characters.
- **UUIDv7 Support:** Extracts embedded timestamps from version 7 UUIDs.
- **Fully Tested:** Includes comprehensive unit tests, covering a range of edge cases.
## Getting Started
```bash
go get github.com/ashwingopalsamy/uuidcheck
```
## How It Works
`IsValidUUID` runs a quick series of checks:
- **Length Check:** Must be exactly 36 characters.
- **Hyphen Positions:** Hyphens must appear at positions 8, 13, 18, and 23.
- **Hex Digits:** All other characters must be valid hex (`0-9`, `A-F`, `a-f`).
`IsUUIDv7` checks the version nibble of the `time_hi_and_version` field, ensuring its '7'.
`UUIDv7ToTimestamp` extracts the first 48 bits from the UUID (the combination of `time_low` and part of `time_mid`) and interprets them as a Unix timestamp in milliseconds.
## Examples
**Valid:**
- `01939c00-282d-782f-9cc2-887dc7b40629`
- `01939C00-282D-782F-9CC2-887DC7B40629`
**Invalid:**
- `01939c-282d-782f-9cc2-887` (too short)
- `f01939c00-282d-782f-9cg2-887dc7b40629` (invalid hex char `g`)
- `01939c00282d782f9cc2887dc7b40629` (no hyphens)
## Testing
We believe in solid test coverage. Just run:
```bash
go test -v ./...
```
You'll find unit tests and edge case scenarios in `uuidcheck_test.go`.
## Contributing
Contributions are welcome!
Feel free to open issues, submit PRs, or propose features. Just keep it simple and aligned with the library’s goal: blazing-fast, straightforward UUID validation.
## License
This project is licensed under the [MIT License](LICENSE).