Use the GUID Regex Go Validator to ensure your unique identifiers follow the correct structure. Test and debug your regex in the Go Regex Tester or validate associated data like emails, URLs, and passwords for a complete data quality workflow.
[A-Z]
: uppercase letters[a-z]
: lowercase letters[0-9]
: digits\.
: a literal dot+
: one or more of the preceding*
: zero or more of the preceding?
: optional (zero or one)^
: start of string$
: end of string
Test your APIs today!
Write in plain English — Qodex turns it into secure, ready-to-run tests.
Regular Expression - Documentation
Introduction: What Is GUID Regex?
In Go (Golang), a GUID (Globally Unique Identifier), also known as a UUID (Universally Unique Identifier), is used to identify resources uniquely across distributed systems. It ensures that no two values are ever the same, making it vital for tracking, versioning, and referencing.
A GUID looks like this:
It contains 32 hexadecimal characters arranged into 5 groups separated by hyphens, following the pattern:
The most reliable way to validate GUID formats in Go is using regular expressions (regex). Regex allows you to match and verify this structure before storing or processing the data.
GUID Regex Pattern (with Breakdown)
Here’s the regex pattern we use to validate a GUID:
Explanation:
[0-9a-fA-F]{8} – First group of 8 hexadecimal digits
- – Hyphen separator
[0-9a-fA-F]{4} – Second group of 4 digits
[1-5][0-9a-fA-F]{3} – Version digit (1–5) + 3 more hex digits
[89abAB][0-9a-fA-F]{3} – Variant digit (starting with 8, 9, a, or b) + 3 hex digits
[0-9a-fA-F]{12} – Final 12 hex digits
How to Validate GUIDs in Go Using Regex
You can validate GUIDs using the regexp package in Go. Here’s the complete Go code:
Real-World Use Cases
Database Primary Keys: Useful for identifying records in distributed databases.
API Resource Identifiers: RESTful services use GUIDs for resources like /user/3f2504e0-4f89-11d3-9a0c-0305e82c3301.
Session Tokens: Web apps often use UUIDs to track secure sessions.
Device or File IDs: Many cloud storage services use GUIDs to uniquely reference files.
Pro Tips
Always use lowercase or uppercase consistently when displaying GUIDs.
Regex validates the format only — not whether the GUID is truly unique.
Never expose GUIDs that relate to sensitive resources in unsecured URLs.
Use regex for validation but libraries like github.com/google/uuid for generation.
For batch testing, use the Go Regex Tester to try different formats quickly.
Combine with These Tools
Use the GUID Regex Go Validator alongside these tools to ensure your data pipeline is complete:
Password Regex Go Validator – Secure password checks
UUID Regex Go Validator – Also checks for version-based UUIDs
Phone Number Regex Go Validator – Useful for user profiles
Email Regex Go Validator – Ensure valid email formats
URL Regex Go Validator – Validate links tied to GUIDs
Go Regex Tester – Experiment with custom regex formats