{"id":37115820,"url":"https://github.com/asmsh/promise","last_synced_at":"2026-01-14T13:35:14.968Z","repository":{"id":57549187,"uuid":"305853393","full_name":"asmsh/promise","owner":"asmsh","description":"Fast, lightweight, and lock-free promises for Go... the Go way. Providing an efficient and idiomatic way for managing and creating asynchronous pipelines in Go.","archived":false,"fork":false,"pushed_at":"2025-11-11T12:40:16.000Z","size":708,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"feat/new-api","last_synced_at":"2025-11-11T14:26:08.060Z","etag":null,"topics":["async","asynchronous","futures","go","golang","goroutine","library","pipeline","promise","promises"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asmsh.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-10-20T23:03:34.000Z","updated_at":"2025-11-11T12:40:20.000Z","dependencies_parsed_at":"2024-06-20T10:16:28.415Z","dependency_job_id":"ad958af6-8c9b-433a-9d8d-cbc9ad41752f","html_url":"https://github.com/asmsh/promise","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/asmsh/promise","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fpromise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fpromise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fpromise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fpromise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asmsh","download_url":"https://codeload.github.com/asmsh/promise/tar.gz/refs/heads/feat/new-api","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fpromise/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28421308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["async","asynchronous","futures","go","golang","goroutine","library","pipeline","promise","promises"],"created_at":"2026-01-14T13:35:13.127Z","updated_at":"2026-01-14T13:35:14.957Z","avatar_url":"https://github.com/asmsh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Promise\n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/asmsh/promise)](https://pkg.go.dev/github.com/asmsh/promise)\n[![Go Report Card](https://goreportcard.com/badge/github.com/asmsh/promise)](https://goreportcard.com/report/github.com/asmsh/promise)\n[![Tests](https://github.com/asmsh/promise/workflows/Tests/badge.svg)](https://github.com/asmsh/promise/actions)\n[![Go Coverage](https://github.com/asmsh/promise/wiki/coverage.svg)](https://raw.githack.com/wiki/asmsh/promise/coverage.html)\n\n*Fast, lightweight, and lock-free promises for Go... the Go way*\n\n## NOTE: this branch is still a work in progress, and the below guide is not up to date.\n\n## Features\n\n* Fast and low memory overhead implementation\n* Lock-free implementation\n* Extensible implementation that can be used to provide typed promises\n* Automatic panic recovering\n* An API that focuses on Go's idioms, like:\n\t* Multi return parameters\n\t* Error being a value\n\t* The convention of returning errors as the last return parameter\n\t* The existence of panics and their difference from errors.\n\n## Overview\n\n### What's a Promise ?\n\nA Promise represents some asynchronous work. It offers ways to get the eventual result of that asynchronous work.  \nRead more on [its Wiki page](https://en.wikipedia.org/wiki/Futures_and_promises).\n\n### Why in Go ?\n\nWaiting for a *goroutine*, or returning result from a *goroutine*, specially with multi return parameters, can get\ntedious, as it usually requires using more than one variable(a channel with a *struct* type whose fields correspond to\nthe return parameters, or a `sync.WaitGroup` with some variables).\n\nBut using a promise, it's now possible to wait for the corresponding *goroutine* to finish and/or access the returned\nresult from it, along with other features, like knowing the status of that *goroutine*, building computation pipelines,\nand recovering from panics.\n\n## Installation\n\n\u003e go get github.com/asmsh/promise\n\n**Note:** some breaking changes maybe present between each minor version, until the release of v1.0.0, so always check\nthe changelog before updating.\n\n### Prerequisites\n\nGo 1.13+\n\n## Usage\n\n### Basic Usage:\n\n* If you want to return some values from a *goroutine*:\n\n```go\np := promise.GoRes(func () promise.Res {\n\t/* do some work, asynchronously */\n\treturn promise.Res{\"go\", \"golang\"} // return any values(as elements)\n})\n```\n\n* If you don't want to return any values:\n\n```go\np := promise.Go(func () {\n\t/* do some work, asynchronously */\n})\n```\n\nThen use any of `p`'s methods to wait for it, access its result, or create a pipeline.\n\n## Examples\n\n* The simplest use case, is to use it as a `sync.WaitGroup` with only one task:\n\n```go\npackage main\n\nimport \"github.com/asmsh/promise\"\n\nfunc main() {\n\tp := promise.Go(func() {\n\t\t/* do some work, asynchronously */\n\t})\n\n\t/* do some other work */\n\n\tp.Wait() // wait for the async work to finish\n\n\t/* do some other work */\n}\n\n```\n\nThe following code is equivalent to the previous, but using only the standard library:\n\n```go\npackage main\n\nimport \"sync\"\n\nfunc main() {\n\twg := \u0026sync.WaitGroup{}\n\twg.Add(1)\n\tgo func(wg *sync.WaitGroup) {\n\t\t/* do some work, asynchronously */\n\t\twg.Done()\n\t}(wg)\n\n\t/* do some other work */\n\n\twg.Wait() // wait for the async work to finish\n\n\t/* do some other work */\n}\n```\n\n* A typical use case, is to use it to return some result from a goroutine:\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/asmsh/promise\"\n)\n\nfunc main() {\n\tp := promise.GoRes(func() promise.Res {\n\t\tresp, err := http.Get(\"https://golang.org/\")\n\t\treturn promise.Res{resp, err}\n\t}).Then(func(res promise.Res, ok bool) promise.Res {\n\t\t// uncomment the following and do something with resp..\n\t\t//resp := res[0].(*http.Response)\n\t\treturn nil\n\t}).Catch(func(err error, res promise.Res, ok bool) promise.Res {\n\t\t// handle the error..\n\t\treturn nil\n\t})\n\n\t/* do some other work */\n\n\tp.Wait() // wait for all the work to finish\n\n\t/* do some other work */\n}\n```\n\n* It can be embedded or extended, to provide typed promises, like\n  the [asyncHttp](https://github.com/asmsh/promise/tree/main/examples/asyncHttp), or\n  the [ctxProm](https://github.com/asmsh/promise/tree/main/examples/ctxProm) examples.\n\n* It provides JavaScript-like Resolver constructor, which can be used like\n  in [this example.](https://github.com/asmsh/promise/tree/main/examples/resolver)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmsh%2Fpromise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasmsh%2Fpromise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmsh%2Fpromise/lists"}