{"id":34821659,"url":"https://github.com/go-god/wrap","last_synced_at":"2026-05-24T03:33:49.038Z","repository":{"id":61624059,"uuid":"537757076","full_name":"go-god/wrap","owner":"go-god","description":"wrap go goroutine run.","archived":false,"fork":false,"pushed_at":"2022-09-19T14:32:50.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-24T03:33:41.391Z","etag":null,"topics":["go","goroutine","waitgroup","wrap","wrapper"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/go-god/wrap","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/go-god.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":"2022-09-17T09:18:24.000Z","updated_at":"2022-09-19T14:27:46.000Z","dependencies_parsed_at":"2022-10-19T18:45:24.311Z","dependency_job_id":null,"html_url":"https://github.com/go-god/wrap","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/go-god/wrap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-god%2Fwrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-god%2Fwrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-god%2Fwrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-god%2Fwrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-god","download_url":"https://codeload.github.com/go-god/wrap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-god%2Fwrap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33420660,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T22:14:44.296Z","status":"online","status_checked_at":"2026-05-24T02:00:06.296Z","response_time":57,"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","goroutine","waitgroup","wrap","wrapper"],"created_at":"2025-12-25T14:46:32.735Z","updated_at":"2026-05-24T03:33:49.029Z","avatar_url":"https://github.com/go-god.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wrap\n- wrap go `sync.WaitGroup` processing goroutine\n- wrap go `chan` processing goroutine\n\n# why wrap\n- Wrap the go `sync.WaitGroup` so that you don't sometimes forget to write `defer wg.Add(1)` before the business layer writes go func, or `defer wg.Done()` when it's Done.\n- By wrapping it, you can ensure that the Go Goroutine executes successfully.\n\n# example\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/go-god/wrap\"\n)\n\nfunc main() {\n\t// through wg to exec goroutine\n\tvar wg = wrap.New()\n\twg.Wrap(func() {\n\t\tlog.Println(\"this is test\")\n\t})\n\n\tfor i := 0; i \u003c 10; i++ {\n\t\tnum := i\n\t\t// wrap go goroutine without recovery func\n\t\twg.Wrap(func() {\n\t\t\tlog.Println(\"current index:\", num)\n\t\t})\n\t}\n\n\twg.WrapWithRecovery(func() {\n\t\tlog.Println(\"exec goroutine with recovery func\")\n\t\tvar s = []string{\"a\", \"b\", \"c\"}\n\t\tlog.Printf(\"s[3] = %v\", s[3])\n\t}, func(r interface{}) {\n\t\t// exec recover:runtime error: index out of range [3] with length 3\n\t\tlog.Printf(\"exec recover:%v\", r)\n\t})\n\n\twg.Wait()\n\n\t// through chan to exec goroutine\n\tw := wrap.NewChanWrapper(2)\n\tw.Wrap(func() {\n\t\tlog.Println(\"this is test\")\n\t})\n\n\tw.WrapWithRecovery(func() {\n\t\tlog.Println(\"exec goroutine with recovery func\")\n\t\tvar s = []string{\"a\", \"b\", \"c\"}\n\t\tlog.Printf(\"s[3] = %v\", s[3])\n\t}, func(r interface{}) {\n\t\t// exec recover:runtime error: index out of range [3] with length 3\n\t\tlog.Printf(\"exec recover:%v\", r)\n\t})\n\n\tw.Wait()\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-god%2Fwrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-god%2Fwrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-god%2Fwrap/lists"}