{"id":17337885,"url":"https://github.com/yitter/idgenerator-go","last_synced_at":"2025-04-14T16:33:21.740Z","repository":{"id":38315346,"uuid":"352502937","full_name":"yitter/idgenerator-go","owner":"yitter","description":"idgenerator 的 Go 专项引用库。","archived":false,"fork":false,"pushed_at":"2023-05-25T15:08:06.000Z","size":213,"stargazers_count":31,"open_issues_count":1,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-06-18T17:12:21.407Z","etag":null,"topics":["golang","idgenerator","snowflake"],"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/yitter.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":"2021-03-29T03:18:22.000Z","updated_at":"2024-05-24T07:27:45.000Z","dependencies_parsed_at":"2024-06-18T16:59:56.253Z","dependency_job_id":"1b275ee5-5407-469c-ab7b-191e380f8f7e","html_url":"https://github.com/yitter/idgenerator-go","commit_stats":{"total_commits":67,"total_committers":8,"mean_commits":8.375,"dds":0.6119402985074627,"last_synced_commit":"914a0ad6eb9118f2b0a94a7781cb6518d9aefac2"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yitter%2Fidgenerator-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yitter%2Fidgenerator-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yitter%2Fidgenerator-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yitter%2Fidgenerator-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yitter","download_url":"https://codeload.github.com/yitter/idgenerator-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219843449,"owners_count":16556506,"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":["golang","idgenerator","snowflake"],"created_at":"2024-10-15T15:36:31.387Z","updated_at":"2024-10-15T15:36:31.483Z","avatar_url":"https://github.com/yitter.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  ❄ idgenerator-Go\r\n\r\n## 介绍\r\n项目更多介绍参照：https://github.com/yitter/idgenerator\r\n\r\n## 引用全局库\r\n```\r\ngo get -u -v github.com/yitter/idgenerator-go@v1.3.1\r\n```\r\n\r\n## 调用示例（Go）\r\n\r\n第1步，**全局** 初始化（应用程序启动时执行一次）：\r\n```\r\n// 创建 IdGeneratorOptions 对象，请在构造函数中输入 WorkerId：\r\nvar options = idgen.NewIdGeneratorOptions(1)\r\n// options.WorkerIdBitLength = 10 // WorkerIdBitLength 默认值6，支持的 WorkerId 最大值为2^6-1，若 WorkerId 超过64，可设置更大的 WorkerIdBitLength\r\n// ...... 其它参数设置参考 IdGeneratorOptions 定义，一般来说，只要再设置 WorkerIdBitLength （决定 WorkerId 的最大值）。\r\n\r\n// 保存参数（必须的操作，否则以上设置都不能生效）：\r\nidgen.SetIdGenerator(options)\r\n// 以上初始化过程只需全局一次，且必须在第2步之前设置。\r\n```\r\n\r\n第2步，生成ID：\r\n```\r\n// 初始化以后，即可在任何需要生成ID的地方，调用以下方法：\r\nvar newId = idgen.NextId()\r\n```\r\n\r\n## 关于Go环境\r\n\r\n1.SDK，go1.17\r\n\r\n2.启用 Go-Modules\r\n```\r\ngo env -w GO111MODULE=on\r\n\r\n# Next *ONLY* for China-Users:\r\ngo env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct\r\n```\r\n\r\n## 代码贡献者(按时间顺序)\r\nguoyahao | amuluowin | houseme\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyitter%2Fidgenerator-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyitter%2Fidgenerator-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyitter%2Fidgenerator-go/lists"}