{"id":22967785,"url":"https://github.com/jabolopes/go-cancelgroup","last_synced_at":"2025-06-16T07:07:40.969Z","repository":{"id":57581653,"uuid":"329100893","full_name":"jabolopes/go-cancelgroup","owner":"jabolopes","description":"A WaitGroup with support for group cancellation and context cancellation.","archived":false,"fork":false,"pushed_at":"2022-08-20T22:37:43.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T05:19:09.557Z","etag":null,"topics":["go","go-library","golang","golang-library","synchronization","utility","waitgroup","waitgroups"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jabolopes.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":"2021-01-12T20:13:07.000Z","updated_at":"2024-07-29T18:46:39.000Z","dependencies_parsed_at":"2022-09-26T19:31:21.327Z","dependency_job_id":null,"html_url":"https://github.com/jabolopes/go-cancelgroup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jabolopes/go-cancelgroup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabolopes%2Fgo-cancelgroup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabolopes%2Fgo-cancelgroup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabolopes%2Fgo-cancelgroup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabolopes%2Fgo-cancelgroup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabolopes","download_url":"https://codeload.github.com/jabolopes/go-cancelgroup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabolopes%2Fgo-cancelgroup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260116643,"owners_count":22961064,"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","go-library","golang","golang-library","synchronization","utility","waitgroup","waitgroups"],"created_at":"2024-12-14T21:14:44.034Z","updated_at":"2025-06-16T07:07:40.935Z","avatar_url":"https://github.com/jabolopes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-cancelgroup\n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/jabolopes/go-cancelgroup)](https://pkg.go.dev/github.com/jabolopes/go-cancelgroup)\n\nThis package provides `cancelgroup.Group`, which is a `sync.WaitGroup` with\nsupport for group cancellation and context cancellation. When the context is\ncancelled, the `cancelgroup.Group` is also cancelled and attempting to further\nschedule goroutines on this group is a no-op.\n\n## Installation\n\n```sh\n$ go get github.com/jabolopes/go-cancelgroup\n```\n\nYou can use `go get -u` to update the package. If you are using Go modules, you\ncan also just import the package and it will be automatically downloaded on the\nfirst compilation.\n\n## Examples\n\nTypical usage of a `cancelgroup.Group` with group cancellation:\n\n```go\ng := cancelgroup.New(ctx)\n\n// Schedule some goroutines.\nfor i := 0; i \u003c 10; i++ {\n  g.Go(func(ctx context.Context) { ... })\n}\n\n// Do something else...\n\n// Cancel group.\ng.Cancel()\n\n// Wait for active goroutines to finish.\ng.Wait()\n```\n\nExample of a usage of a `cancelgroup.Group` with Context cancellation:\n\n```go\n// Create a context with cancellation. Can also be a `context.WithDeadline`, a `context.WithTimeout`, etc.\nctx, cancel := context.WithCancel(ctx)\n\ng := cancelgroup.New(ctx)\n\n// Schedule some goroutines.\nfor i := 0; i \u003c 10; i++ {\n  g.Go(func(ctx context.Context) { ... })\n}\n\n// Cancel the context.\ncancel()\n\n// Scheduling goroutines on the already cancelled group is a no-op\ng.Go(func(ctx context.Context) { ... })\n\n// Wait for active goroutines to finish.\ng.Wait()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabolopes%2Fgo-cancelgroup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabolopes%2Fgo-cancelgroup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabolopes%2Fgo-cancelgroup/lists"}