{"id":17176108,"url":"https://github.com/upbit/goalbatch","last_synced_at":"2026-06-29T03:31:06.583Z","repository":{"id":57516883,"uuid":"245575412","full_name":"upbit/goalbatch","owner":"upbit","description":"A simple way to execute functions asynchronously and waits for results","archived":false,"fork":false,"pushed_at":"2020-03-10T02:00:05.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-06T12:26:01.913Z","etag":null,"topics":["asynchronous","batch","coroutines","golang"],"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/upbit.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":"2020-03-07T05:39:46.000Z","updated_at":"2023-01-10T10:11:52.000Z","dependencies_parsed_at":"2022-09-15T21:50:39.930Z","dependency_job_id":null,"html_url":"https://github.com/upbit/goalbatch","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/upbit/goalbatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upbit%2Fgoalbatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upbit%2Fgoalbatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upbit%2Fgoalbatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upbit%2Fgoalbatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/upbit","download_url":"https://codeload.github.com/upbit/goalbatch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upbit%2Fgoalbatch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34912252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"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":["asynchronous","batch","coroutines","golang"],"created_at":"2024-10-14T23:59:05.069Z","updated_at":"2026-06-29T03:31:06.565Z","avatar_url":"https://github.com/upbit.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"goalbatch\n================\n[![goalbatch badge](https://github.com/upbit/goalbatch/workflows/goalbatch/badge.svg)](https://github.com/upbit/goalbatch/actions?query=workflow%3Agoalbatch)\n[![Go Report Card](https://goreportcard.com/badge/github.com/upbit/goalbatch)](https://goreportcard.com/report/github.com/upbit/goalbatch)\n[![codecov](https://codecov.io/gh/upbit/goalbatch/branch/master/graph/badge.svg)](https://codecov.io/gh/upbit/goalbatch)\n[![](https://godoc.org/github.com/upbit/goalbatch?status.svg)](http://godoc.org/github.com/upbit/goalbatch)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/upbit/goalbatch/blob/master/LICENSE)\n\ngoalbatch - A simple way to execute functions asynchronously and waits for results\n\n## Batch\n\u003e Batch method returns when all of the callbacks passed or context is done, returned responses and errors are ordered according to callback order\n\n```go\n\ttimeout := time.Duration(100) * time.Millisecond\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\n\tg := goalbatch.New(ctx)\n\trs, errs := g.Batch(\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\ttime.Sleep(5 * time.Second)\n\t\t\treturn 1, nil\n\t\t},\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\treturn nil, errors.New(\"failed\")\n\t\t},\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\treturn 3, nil\n\t\t},\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\treturn 4, nil\n\t\t},\n\t)\n\n\tfmt.Println(rs)\n\tfmt.Println(errs)\n\t// Output:\n\t// [\u003cnil\u003e \u003cnil\u003e 3 4]\n\t// [\u003cnil\u003e \"failed\" \u003cnil\u003e \u003cnil\u003e]\n```\n\nOr generate closure functions with parameters:\n\n```go\n\tnewAsyncFunc := func(ctx context.Context, param1 string, param2 int) AsyncFunc {\n\t\treturn func(ctx context.Context) (interface{}, error) {\n\t\t\t// deal with param1, param2...\n\t\t\tresult := fmt.Sprintf(\"p1=%s p2=%d\", param1, param2)\n\t\t\treturn result, nil\n\t\t}\n\t}\n\n\tfns := make([]goalbatch.AsyncFunc, 2)\n\tfns[0] = newAsyncFunc(ctx, \"foo\", 1)\n\tfns[1] = newAsyncFunc(ctx, \"bar\", 2)\n\n\tg := goalbatch.New(ctx)\n\trs, errs := g.Batch(fns...)\n\n\tfmt.Println(rs)\n\tfmt.Println(errs)\n\t// Output:\n\t// [\"p1=foo p2=1\" \"p1=bar p2=2\"]\n\t// [\u003cnil\u003e \u003cnil\u003e]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupbit%2Fgoalbatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fupbit%2Fgoalbatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupbit%2Fgoalbatch/lists"}