{"id":13481351,"url":"https://github.com/sqids/sqids-go","last_synced_at":"2025-12-29T23:37:11.399Z","repository":{"id":176746972,"uuid":"658041587","full_name":"sqids/sqids-go","owner":"sqids","description":"Official Go port of Sqids. Generate short unique IDs from numbers.","archived":false,"fork":false,"pushed_at":"2023-09-11T10:00:20.000Z","size":42,"stargazers_count":541,"open_issues_count":0,"forks_count":13,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-30T15:50:40.986Z","etag":null,"topics":["go","golang","hashids","id","id-generator","short-id","short-url","sqids","uid","unique-id","unique-id-generator"],"latest_commit_sha":null,"homepage":"https://sqids.org/go","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/sqids.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}},"created_at":"2023-06-24T15:27:56.000Z","updated_at":"2024-10-24T08:58:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"9e3774ec-17c0-4aa7-b983-e962d0428cfd","html_url":"https://github.com/sqids/sqids-go","commit_stats":null,"previous_names":["sqids/sqids-go"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqids","download_url":"https://codeload.github.com/sqids/sqids-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245844799,"owners_count":20681778,"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","hashids","id","id-generator","short-id","short-url","sqids","uid","unique-id","unique-id-generator"],"created_at":"2024-07-31T17:00:51.115Z","updated_at":"2025-12-29T23:37:11.352Z","avatar_url":"https://github.com/sqids.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# [Sqids Go](https://sqids.org/go)\n\n[![GoDoc](https://godoc.org/github.com/sqids/sqids-go?status.svg)](https://godoc.org/github.com/sqids/sqids-go)\n[![Github Actions](https://img.shields.io/github/actions/workflow/status/sqids/sqids-go/tests.yml)](https://github.com/sqids/sqids-go/actions)\n\n[Sqids](https://sqids.org/go) (*pronounced \"squids\"*) is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast \u0026 URL-safe ID generation and decoding back into numbers for quicker database lookups.\n\nFeatures:\n\n- **Encode multiple numbers** - generate short IDs from one or several non-negative numbers\n- **Quick decoding** - easily decode IDs back into numbers\n- **Unique IDs** - generate unique IDs by shuffling the alphabet once\n- **ID padding** - provide minimum length to make IDs more uniform\n- **URL safe** - auto-generated IDs do not contain common profanity\n- **Randomized output** - Sequential input provides nonconsecutive IDs\n- **Many implementations** - Support for [40+ programming languages](https://sqids.org/)\n\n## 🧰 Use-cases\n\nGood for:\n\n- Generating IDs for public URLs (eg: link shortening)\n- Generating IDs for internal systems (eg: event tracking)\n- Decoding for quicker database lookups (eg: by primary keys)\n\nNot good for:\n\n- Sensitive data (this is not an encryption library)\n- User IDs (can be decoded revealing user count)\n\n## 🚀 Getting started\n\nUse go get.\n\n```bash\ngo get github.com/sqids/sqids-go\n```\n\nThen import the package into your own code.\n\n```golang\nimport \"github.com/sqids/sqids-go\"\n```\n\n## 👩‍💻 Examples\n\n\u003e **Note**\n\u003e Please note that the following examples omit proper error handling.\n\nSimple encode \u0026 decode:\n\n[embedmd]:# (examples/sqids-encode-decode/sqids-encode-decode.go /.+sqids.New/ /\\[1, 2, 3\\]/)\n```go\n\ts, _ := sqids.New()\n\tid, _ := s.Encode([]uint64{1, 2, 3}) // \"86Rf07\"\n\tnumbers := s.Decode(id)              // [1, 2, 3]\n```\n\n\u003e **Note**\n\u003e 🚧 Because of the algorithm's design, **multiple IDs can decode back into the same sequence of numbers**. If it's important to your design that IDs are canonical, you have to manually re-encode decoded numbers and check that the generated ID matches.\n\nEnforce a *minimum* length for IDs:\n\n[embedmd]:# (examples/sqids-minimum-length/sqids-minimum-length.go /.+sqids.New/ /\\[1, 2, 3\\]/)\n```go\n\ts, _ := sqids.New(sqids.Options{\n\t\tMinLength: 10,\n\t})\n\tid, _ := s.Encode([]uint64{1, 2, 3}) // \"86Rf07xd4z\"\n\tnumbers := s.Decode(id)              // [1, 2, 3]\n```\nRandomize IDs by providing a custom alphabet:\n\n[embedmd]:# (examples/sqids-custom-alphabet/sqids-custom-alphabet.go /.+sqids.New/ /\\[1, 2, 3\\]/)\n```go\n\ts, _ := sqids.New(sqids.Options{\n\t\tAlphabet: \"FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE\",\n\t})\n\tid, _ := s.Encode([]uint64{1, 2, 3}) // \"B4aajs\"\n\tnumbers := s.Decode(id)              // [1, 2, 3]\n```\n\nPrevent specific words from appearing anywhere in the auto-generated IDs:\n\n[embedmd]:# (examples/sqids-blocklist/sqids-blocklist.go /.+sqids.New/ /\\[1, 2, 3\\]/)\n```go\n\ts, _ := sqids.New(sqids.Options{\n\t\tBlocklist: []string{\"86Rf07\"},\n\t})\n\tid, _ := s.Encode([]uint64{1, 2, 3}) // \"se8ojk\"\n\tnumbers := s.Decode(id)              // [1, 2, 3]\n```\n\n## 📝 License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqids%2Fsqids-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqids%2Fsqids-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqids%2Fsqids-go/lists"}