{"id":16714496,"url":"https://github.com/bluele/gosem","last_synced_at":"2025-10-23T15:56:36.903Z","repository":{"id":142827469,"uuid":"53420169","full_name":"bluele/gosem","owner":"bluele","description":"gosem provides multiple semaphore functions. Currently supports inmemory, redis implementation.","archived":false,"fork":false,"pushed_at":"2017-07-14T09:37:20.000Z","size":13,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-22T20:42:19.644Z","etag":null,"topics":["go","golang","redis","semaphore"],"latest_commit_sha":null,"homepage":null,"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/bluele.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":"2016-03-08T14:50:01.000Z","updated_at":"2020-01-10T16:54:42.000Z","dependencies_parsed_at":"2024-06-20T06:07:41.927Z","dependency_job_id":null,"html_url":"https://github.com/bluele/gosem","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bluele/gosem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluele%2Fgosem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluele%2Fgosem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluele%2Fgosem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluele%2Fgosem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bluele","download_url":"https://codeload.github.com/bluele/gosem/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluele%2Fgosem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280647981,"owners_count":26366641,"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","status":"online","status_checked_at":"2025-10-23T02:00:06.710Z","response_time":142,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","redis","semaphore"],"created_at":"2024-10-12T21:05:25.065Z","updated_at":"2025-10-23T15:56:36.863Z","avatar_url":"https://github.com/bluele.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gosem\n\n[![CircleCI](https://circleci.com/gh/bluele/gosem/tree/master.svg?style=svg)](https://circleci.com/gh/bluele/gosem/tree/master)\n\ngosem provides multiple semaphore functions.\nCurrently supports inmemory, redis implementation.\n\n# Example\n\n```go\n// You can set a number of available resources.\nvar sem = gosem.NewSemaphore(3)\n\nfunc main() {\n  for _, task := range tasks {\n    // Do task if available resources exists.\n    sem.Acquire()\n    go func(task Task) {\n      defer sem.Release()\n      do(task)\n    }(task)\n  }\n}\n```\n\n# Features\n\n## Memory-based semaphore\n\n### Simple semaphore\n\nSemaphore is a semaphore that can be used to coordinate the number of accessing shared data from multiple goroutine.\n\n```go\nsem := gosem.NewSemaphore(5)\n// acquire a new resource\nsem.Acquire()\n// release the resource\nsem.Release()\n```\n\n### Time semaphore\n\nTimeSemaphore is a semaphore that can be used to coordinate the number of accessing shared data from multiple goroutine with specified time.\n\n```go\nsem := gosem.NewTimeSemaphore(5, time.Second)\n// acquire a new resource\nsem.Acquire()\n// release the resource\nsem.Release()\n```\n\n## Redis-based semaphore\n\nImplements a semaphore using Redis.\n\nIt can be used between processes that are on the multiple host.\n\n### Counting semaphore\n\n```go\nimport \"gopkg.in/redis.v3\"\n\nclient := redis.NewClient(\n  \u0026redis.Options{Network: \"tcp\", Addr: \"127.0.0.1:6379\"},\n)\nsem := gosem.NewRedisSemaphore(client, 5)\n// acquire a new resource\nsem.Acquire()\n// release the resource\nsem.Release()\n```\n\n\n# Contribution\n\n1. Fork ([https://github.com/bluele/gosem/fork](https://github.com/bluele/gosem/fork))\n1. Create a feature branch\n1. Commit your changes\n1. Rebase your local changes against the master branch\n1. Run test suite with the `go test ./...` command and confirm that it passes\n1. Run `gofmt -s`\n1. Create new Pull Request\n\n# Author\n\n**Jun Kimura**\n\n* \u003chttp://github.com/bluele\u003e\n* \u003cjunkxdev@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluele%2Fgosem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluele%2Fgosem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluele%2Fgosem/lists"}