{"id":23818777,"url":"https://github.com/blackieops/primarykey","last_synced_at":"2026-05-12T12:40:19.625Z","repository":{"id":61625408,"uuid":"540889033","full_name":"blackieops/primarykey","owner":"blackieops","description":"🔑 Human-friendly IDs for your Go models.","archived":false,"fork":false,"pushed_at":"2024-11-03T17:42:48.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-05T17:32:38.402Z","etag":null,"topics":["database","go","golang","library","shortuuid","uuid"],"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/blackieops.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}},"created_at":"2022-09-24T16:12:35.000Z","updated_at":"2024-11-03T17:42:52.000Z","dependencies_parsed_at":"2022-10-18T17:30:38.678Z","dependency_job_id":null,"html_url":"https://github.com/blackieops/primarykey","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blackieops%2Fprimarykey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blackieops%2Fprimarykey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blackieops%2Fprimarykey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blackieops%2Fprimarykey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blackieops","download_url":"https://codeload.github.com/blackieops/primarykey/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240094985,"owners_count":19746790,"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":["database","go","golang","library","shortuuid","uuid"],"created_at":"2025-01-02T06:16:58.532Z","updated_at":"2026-05-07T02:30:19.939Z","avatar_url":"https://github.com/blackieops.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `go.b8s.dev/primarykey`\n\n[![Test Suite](https://github.com/blackieops/primarykey/actions/workflows/tests.yml/badge.svg)](https://github.com/blackieops/primarykey/actions/workflows/tests.yml)\n[![Go Report Card](https://goreportcard.com/badge/go.b8s.dev/primarykey)](https://goreportcard.com/report/go.b8s.dev/primarykey)\n\n`primarykey` is a replacement for UUID primary keys in your database-driven Go\nprograms. `primarykey` utilises the [`shortuuid`][1] library to generate\nbinary-compatible UUIDs in a more human-friendly format, allowing you to still\nbenefit from native UUID storage in systems like PostgreSQL but while providing\nless obnoxious IDs to your users.\n\n[1]: https://github.com/lithammer/shortuuid\n\n## Usage\n\nUse `primarykey.ID` for your ID fields in your model structs:\n\n```go\nimport \"go.b8s.dev/primarykey\"\n\ntype MyModel struct {\n\tID primarykey.ID\n}\n```\n\nThe ID will be passed to the datastore as a regular binary UUID (eg., `uuid` in\nPostgreSQL).\n\nYou can pass primarykeys directly into queries:\n\n```go\ndb.Query(\"SELECT * FROM my_model WHERE id = $1\", myModel.ID)\n```\n\nAnd marshal them to serializable formats like JSON automatically:\n\n```go\nb, _ := json.Marshal(\u0026MyModel{ID: primarykey.New()})\n//=\u003e {\"ID\":\"KwSysDpxcBU9FNhGkn2dCf\"}\n```\n\nThere is also a public interface to encode and decode directly:\n\n```go\nnewOne := primarykey.New()\nprimarykey.Encode(newOne) //=\u003e \"KwSysDpxcBU9FNhGkn2dCf\"\n\nid := primarykey.Decode(\"KwSysDpxcBU9FNhGkn2dCf\") //=\u003e ID\nid.UUID() //=\u003e uuid.UUID\nid.String() //=\u003e \"KwSysDpxcBU9FNhGkn2dCf\"\n```\n\n\n## Development\n\nThis is a very standard Go project with very minimal dependencies and no\nrequired setup. Dependencies are vendored.\n\nTo run the test suite:\n\n```\n$ go test .\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackieops%2Fprimarykey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackieops%2Fprimarykey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackieops%2Fprimarykey/lists"}