{"id":16517626,"url":"https://github.com/rfyiamcool/waitgroup","last_synced_at":"2025-10-26T23:50:47.246Z","repository":{"id":57635633,"uuid":"300634672","full_name":"rfyiamcool/waitgroup","owner":"rfyiamcool","description":"waitgroup that supports context and timeout.","archived":false,"fork":false,"pushed_at":"2020-10-13T05:39:17.000Z","size":5,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-14T17:40:39.010Z","etag":null,"topics":["waitgroup"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rfyiamcool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-02T14:08:30.000Z","updated_at":"2022-03-03T14:53:00.000Z","dependencies_parsed_at":"2022-09-26T20:21:22.691Z","dependency_job_id":null,"html_url":"https://github.com/rfyiamcool/waitgroup","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rfyiamcool/waitgroup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfyiamcool%2Fwaitgroup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfyiamcool%2Fwaitgroup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfyiamcool%2Fwaitgroup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfyiamcool%2Fwaitgroup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rfyiamcool","download_url":"https://codeload.github.com/rfyiamcool/waitgroup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfyiamcool%2Fwaitgroup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281191587,"owners_count":26458805,"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-26T02:00:06.575Z","response_time":61,"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":["waitgroup"],"created_at":"2024-10-11T16:33:02.686Z","updated_at":"2025-10-26T23:50:47.217Z","avatar_url":"https://github.com/rfyiamcool.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# waitgroup\n\n`extend std waitgroup`\n\n**feature:**\n\n- easy api\n- add timeout\n- add context\n- concurrency go func\n\n`when waitgroup force to exit with timeout, may cause goroutines leak problem.`\n\n## usage:\n\nsee more example in test\n\n[example](waitgroup_test.go)\n\n```go\nfunc Test_Simple(t *testing.T) {\n\tcounter := 0\n\tlock := sync.Mutex{}\n\tfn := func() error {\n\t\tlock.Lock()\n\t\tdefer lock.Unlock()\n\n\t\tcounter++\n\t\treturn nil\n\t}\n\n\twg, ctx := New()\n\twg.Async(fn)\n\twg.AsyncMany(fn, 5)\n\n\t\u003c-ctx.Done()\n\twg.Wait()\n\n\tassert.Equal(t, wg.IsError(), false)\n\tassert.Equal(t, counter, 6)\n}\n\nfunc Test_Ctx(t *testing.T) {\n\tcounter := 0\n\tlock := sync.Mutex{}\n\tfn := func() error {\n\t\tlock.Lock()\n\t\tdefer lock.Unlock()\n\n\t\tcounter++\n\t\treturn nil\n\t}\n\n\terrval := errors.New(\"errfn\")\n\terrfn := func() error {\n\t\tlock.Lock()\n\t\tdefer lock.Unlock()\n\n\t\tcounter++\n\t\treturn errval\n\t}\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\twg, cctx := NewWithContext(ctx)\n\twg.Async(errfn)\n\twg.AsyncMany(fn, 5)\n\n\tselect {\n\tcase \u003c-cctx.Done():\n\tcase \u003c-ctx.Done():\n\t}\n\n\tassert.Equal(t, counter, 6)\n\tassert.Equal(t, wg.IsError(), true)\n\tassert.Equal(t, errval, wg.Errs[0])\n}\n\nfunc Test_WaitTimeout(t *testing.T) {\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\twg, cctx := NewWithContext(ctx)\n\t// _ = cctx\n\n\twg.Async(\n\t\tfunc() error {\n\t\t\ttime.Sleep(5 * time.Second)\n\t\t\treturn io.ErrClosedPipe\n\t\t},\n\t)\n\n\twg.WaitTimeout(1 * time.Second)\n\t\u003c-cctx.Done()\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frfyiamcool%2Fwaitgroup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frfyiamcool%2Fwaitgroup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frfyiamcool%2Fwaitgroup/lists"}