{"id":19232272,"url":"https://github.com/flexstack/uuid","last_synced_at":"2025-06-22T07:03:30.943Z","repository":{"id":240281353,"uuid":"802175785","full_name":"flexstack/uuid","owner":"flexstack","description":"Faster, more flexible v4 and v7 UUIDs in Go","archived":false,"fork":false,"pushed_at":"2024-05-17T18:12:39.000Z","size":28,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T11:32:13.924Z","etag":null,"topics":["go-uuid","uuid","uuid-generator","uuid-go","uuid-parser","uuid-v4","uuid-v7","uuid4","uuid7","uuidv4","uuidv7"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/flexstack/uuid","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flexstack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-17T17:04:02.000Z","updated_at":"2024-07-08T22:07:00.000Z","dependencies_parsed_at":"2024-05-17T19:27:14.265Z","dependency_job_id":"9aac65a4-d09f-4f36-b9af-4b300e4e9da6","html_url":"https://github.com/flexstack/uuid","commit_stats":null,"previous_names":["flexstack/uuid"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/flexstack/uuid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexstack%2Fuuid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexstack%2Fuuid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexstack%2Fuuid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexstack%2Fuuid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flexstack","download_url":"https://codeload.github.com/flexstack/uuid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexstack%2Fuuid/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261250207,"owners_count":23130537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go-uuid","uuid","uuid-generator","uuid-go","uuid-parser","uuid-v4","uuid-v7","uuid4","uuid7","uuidv4","uuidv7"],"created_at":"2024-11-09T16:05:49.752Z","updated_at":"2025-06-22T07:03:25.931Z","avatar_url":"https://github.com/flexstack.png","language":"Go","readme":"# uuid\n\nFaster, more flexible v4 and v7 UUIDs in Go\n\n## Features\n\n- [x] Generate and parse v4 and v7 UUIDs\n- [x] Canonical, hash, and base58 encoding\n- [x] Select a default string format (i.e. base58, hash, canonical)\n- [x] SQL scanning and JSON marshaling\n- [x] The fastest UUID parsing available in Golang\n\n## Installation\n\n```bash\ngo get github.com/flexstack/uuid\n```\n\n## Usage\n\n```go\nimport \"github.com/flexstack/uuid\"\n\n// Optionally set a default format\nuuid.DefaultFormat = uuid.FormatBase58\n\n// Generate a new v4 UUID\nu := uuid.Must(uuid.NewV4())\n\n// Generate a new v7 UUID\nu := uuid.Must(uuid.NewV7())\n\n// Parse a UUID\nu, err := uuid.FromString(\"6ba7b810-9dad-11d1-80b4-00c04fd430c8\")\n\n// Parse a UUID from a byte slice\nu, err := uuid.FromBytes([]byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8})\n\n// Format a UUID\nasHash := u.Format(uuid.FormatHash)\nasBase58 := u.Format(uuid.FormatBase58)\nasCanonical := u.Format(uuid.FormatCanonical)\n\n// Scan a SQL UUID\nvar u uuid.UUID\nerr := db.QueryRow(\"SELECT id FROM users WHERE email = $1\", email).Scan(\u0026u)\nif u.IsNil() {\n    // Handle nil UUID\n}\n```\n\n## Setting a default format\n\nChanging the default format will affect how UUIDs are marshaled to strings from `MarshalText`, and `MarshalJSON`.\n\n\n```go\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/flexstack/uuid\"\n)\n\nfunc main() {\n\tuuid.DefaultFormat = uuid.FormatBase58\n\n\tu := uuid.FromStringOrNil(\"ffffffff-ffff-ffff-ffff-ffffffffffff\")\n\n\t// Marshal to base58\n\tm := map[string]uuid.UUID{\"id\": u}\n\tb, _ := json.Marshal(m)\n\tfmt.Println(string(b)) // {\"id\": \"YcVfxkQb6JRzqk5kF2tNLv\"}\n}\n```\n\n## Credit\n\nThis package is a fork of [github.com/gofrs/uuid](https://github.com/gofrs/uuid) with the following changes:\n\n- 2x improvement to `FromString`, `UnmarshalText`, and `UnmarshalJSON` performance\n- Adds base58 encoding.\n- Allows people to set a default format (i.e. base58, hash, canonical)\n- Scans nil UUIDs from SQL databases as nil UUIDs (00000000-0000-0000-0000-000000000000) instead of `nil`.\n- Fixes issue with [TimestampFromV7](https://github.com/gofrs/uuid/issues/128) not being spec compliant.\n- Removed v1, v3, v5 UUIDs.\n- Removed support for braced and URN string formats.\n\n## Benchmarks\n\nMacBook Air (15-inch, M2, 2023) Apple M2, 24GB RAM, MacOS 14.4.1\n\n### Format()\n```\nFormat(FormatCanonical)        44625793         26.54 ns/op           48 B/op          1 allocs/op\nFormat(FormatHash)             44022964         26.85 ns/op           32 B/op          1 allocs/op\nFormat(FormatBase58)           5350190          224.0 ns/op           24 B/op          1 allocs/op\n```\n\n### FromString()\n```\nFromString(FormatCanonical)    70893008         16.88 ns/op           0 B/op           0 allocs/op\nFromString(FormatBase58)       16760137         71.77 ns/op           0 B/op           0 allocs/op\n```\n\n### NewVx()\n```\nNewV4()                        2961621          401.6 ns/op           16 B/op          1 allocs/op\nNewV7()                        3859464          308.7 ns/op           16 B/op          1 allocs/op\n```\n\n## Contributing\n\nRead the [CONTRIBUTING.md](CONTRIBUTING.md) guide to learn how to contribute to this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflexstack%2Fuuid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflexstack%2Fuuid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflexstack%2Fuuid/lists"}