{"id":18326488,"url":"https://github.com/ghosind/go-async","last_synced_at":"2026-02-09T21:07:43.278Z","repository":{"id":202815294,"uuid":"708194981","full_name":"ghosind/go-async","owner":"ghosind","description":"Asynchronous workflow utilities for Golang.","archived":false,"fork":false,"pushed_at":"2024-12-10T14:58:12.000Z","size":204,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T19:22:47.301Z","etag":null,"topics":["async","async-library","go","go-library","go-module","golang","workflow"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/ghosind/go-async","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/ghosind.png","metadata":{"files":{"readme":"README-CN.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":"2023-10-21T20:06:30.000Z","updated_at":"2024-12-09T07:37:54.000Z","dependencies_parsed_at":"2024-02-08T10:26:22.883Z","dependency_job_id":"f2a9b7c2-59ea-4f88-835a-28387a821fd4","html_url":"https://github.com/ghosind/go-async","commit_stats":null,"previous_names":["ghosind/go-async"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghosind%2Fgo-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghosind%2Fgo-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghosind%2Fgo-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghosind%2Fgo-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghosind","download_url":"https://codeload.github.com/ghosind/go-async/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654026,"owners_count":21140236,"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":["async","async-library","go","go-library","go-module","golang","workflow"],"created_at":"2024-11-05T19:07:03.801Z","updated_at":"2026-02-09T21:07:43.273Z","avatar_url":"https://github.com/ghosind.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-async\n\n![test](https://github.com/ghosind/go-async/workflows/test/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ghosind/go-async)](https://goreportcard.com/report/github.com/ghosind/go-async)\n[![codecov](https://codecov.io/gh/ghosind/go-async/branch/main/graph/badge.svg)](https://codecov.io/gh/ghosind/go-async)\n![Version Badge](https://img.shields.io/github/v/release/ghosind/go-async)\n![License Badge](https://img.shields.io/github/license/ghosind/go-async)\n[![Go Reference](https://pkg.go.dev/badge/github.com/ghosind/go-async.svg)](https://pkg.go.dev/github.com/ghosind/go-async)\n\n简体中文 | [English](./README.md)\n\nGolang异步工具集，启发自[JavaScript的`Promise`对象](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)以及[Node.js async包](https://caolan.github.io/async/v3/).\n\n## 安装与要求\n\n执行下面的命令以安装本工具集，由于依赖的关系，对Golang的版本需要为1.18及以后版本。\n\n```sh\ngo get -u github.com/ghosind/go-async\n```\n\n安装后在Go项目源码中导入。\n\n```go\nimport \"github.com/ghosind/go-async\"\n```\n\n\u003e [!NOTE]\n\u003e 本工具集尚未稳定，后续版本可能会有不兼容的更改。\n\n## 入门\n\n下面的代码中，通过`All`函数并发执行函数直到全部执行完成，并返回它们的返回结果。\n\n```go\nout, err := async.All(func (ctx context.Context) (int, error) {\n  return 0, nil\n}, func () (string, error)) {\n  time.Sleep(100 * time.Millisecond)\n  return \"hello\", nil\n})\n// out: [][]any{{0, \u003cnil\u003e}, {\"hello\", \u003cnil\u003e}}\n// err: \u003cnil\u003e\n```\n\n本工具集中包含有超过十个异步控制方法，请前往[Go Reference](https://pkg.go.dev/github.com/ghosind/go-async)获取详细的文档及示例。\n\n## 允许的函数\n\n本工具集中大部分的工具方法接受一个任意参数及返回值的函数并执行，但为了最好的效果，建议将第一个参数设置为`context.Context`以接收信号，并将最后一个返回值的类型设置为`error`用于告知工具方法是否发生了错误。\n\n## 自定义上下文\n\n对于所有的工具方法，都有`XXXWithContext`版本（例如`AllWithContext`、`RaceWithContext`等），可以使用该版本传递自定义上下文。\n\n## 可用的工具方法\n\n- [`All`](https://pkg.go.dev/github.com/ghosind/go-async#All)\n- [`AllCompleted`](https://pkg.go.dev/github.com/ghosind/go-async#AllCompleted)\n- [`Fallback`](https://pkg.go.dev/github.com/ghosind/go-async#Fallback)\n- [`Forever`](https://pkg.go.dev/github.com/ghosind/go-async#Forever)\n- [`Parallel`](https://pkg.go.dev/github.com/ghosind/go-async#Parallel)\n- [`ParallelCompleted`](https://pkg.go.dev/github.com/ghosind/go-async#ParallelCompleted)\n- [`Race`](https://pkg.go.dev/github.com/ghosind/go-async#Race)\n- [`Retry`](https://pkg.go.dev/github.com/ghosind/go-async#Retry)\n- [`Seq`](https://pkg.go.dev/github.com/ghosind/go-async#Seq)\n- [`SeqGroups`](https://pkg.go.dev/github.com/ghosind/go-async#SeqGroups)\n- [`Series`](https://pkg.go.dev/github.com/ghosind/go-async#Series)\n- [`Times`](https://pkg.go.dev/github.com/ghosind/go-async#Times)\n- [`TimesLimit`](https://pkg.go.dev/github.com/ghosind/go-async#TimesLimit)\n- [`TimesSeries`](https://pkg.go.dev/github.com/ghosind/go-async#TimesSeries)\n- [`Until`](https://pkg.go.dev/github.com/ghosind/go-async#Until)\n- [`While`](https://pkg.go.dev/github.com/ghosind/go-async#While)\n\n## 许可\n\n本项目通过MIT许可发布，请通过license文件获取该许可的详细信息。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghosind%2Fgo-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghosind%2Fgo-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghosind%2Fgo-async/lists"}