{"id":21423208,"url":"https://github.com/trilliot/safeid","last_synced_at":"2026-01-03T01:19:32.814Z","repository":{"id":264215865,"uuid":"892319794","full_name":"trilliot/safeid","owner":"trilliot","description":"Go type-safe identifiers made easy","archived":false,"fork":false,"pushed_at":"2024-11-28T17:43:16.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T07:11:23.239Z","etag":null,"topics":["go","golang","human-readable","id","identifier","type-safe","uuid","uuidv7"],"latest_commit_sha":null,"homepage":"","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/trilliot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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-11-21T22:25:57.000Z","updated_at":"2024-11-28T17:42:42.000Z","dependencies_parsed_at":"2025-01-23T07:10:59.213Z","dependency_job_id":"a7c015ba-a858-45ec-8b35-2a91fd2fbee2","html_url":"https://github.com/trilliot/safeid","commit_stats":null,"previous_names":["trilliot/safeid"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trilliot%2Fsafeid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trilliot%2Fsafeid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trilliot%2Fsafeid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trilliot%2Fsafeid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trilliot","download_url":"https://codeload.github.com/trilliot/safeid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243926661,"owners_count":20370019,"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","golang","human-readable","id","identifier","type-safe","uuid","uuidv7"],"created_at":"2024-11-22T21:15:06.650Z","updated_at":"2026-01-03T01:19:32.760Z","avatar_url":"https://github.com/trilliot.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SafeID\n\n#### A human-readable, K-sortable, type-safe at compile-time, UUIDv7-backed globally unique identifiers for Go.\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nWhen dealing with commonly accepted unique identifiers such as UUIDs, \nit is hard to know what they represent at first glance.\n\nSafeIDs are designed to be:\n\n- **human readable:** SafeIDs are prefixed by a _type_, followed by a 22 characters string (e.g.: `user_02Yjy1AYf1ckS6jBZ5zw3G`)\n- **K-sortable:** based on the UUIDv7 specification, both UUID or String representation of a SafeID are K-sortable \n- **type-safe:** it is not possible to parse one SafeID type into another when dealing with their string representation\n- **compile-time safe:** thanks to generics, your code will not compile if you try to pass one SafeID type into another\n- **database efficient:** when stored into a database, SafeID can leverage `uuid` column types\n\n## Installation\n\n```\ngo get github.com/trilliot/safeid\n```\n\n## Usage\n\nYou can create either generic (`safeid.Generic`) or custom typed SafeID:\n```go\n// Create a generic type without prefix (not recommended)\nid, err := safeid.New[safeid.Generic]()\n\n// Or create a custom type that satisfies the safeid.Prefixer interface\ntype User struct {}\nfunc (User) Prefix() string { return \"user\" }\n\nid, err := safeid.New[User]()\n```\n\nAn SafeID can be retrieved in its String or UUID form:\n```go\nid.String() // user_02Yjy1AYf1ckS6jBZ5zw3G\nid.UUID()   // 0193508b-e85e-7812-ba4b-91d85495d7bc\n```\n\nWhen dealing with JSON, the type-safe form is (un)marshaled:\n```go\nobj := map[string]any{\n\t\"id\": safeid.Must(safeid.New[User]()),\n}\njson.Marshal(obj, ...) // {\"id\": \"user_02Yjy1AYf1ckS6jBZ5zw3G\"}\n```\n\nWhen passed to or scanned from PostgreSQL, the UUID form is used:\n```go\nvar id safeid.ID[User]\nrows.Scan(\u0026id) // 0193508b-e85e-7812-ba4b-91d85495d7bc\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrilliot%2Fsafeid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrilliot%2Fsafeid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrilliot%2Fsafeid/lists"}