{"id":16100521,"url":"https://github.com/elgohr/go-await","last_synced_at":"2025-04-05T23:42:01.108Z","repository":{"id":92218568,"uuid":"163735067","full_name":"elgohr/go-await","owner":"elgohr","description":"Testing concurrency in Go","archived":false,"fork":false,"pushed_at":"2019-06-04T06:32:01.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-01T12:35:20.469Z","etag":null,"topics":["await","concurrency","go","golang","testing","testing-tools"],"latest_commit_sha":null,"homepage":"","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/elgohr.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}},"created_at":"2019-01-01T12:29:24.000Z","updated_at":"2024-06-19T08:03:17.556Z","dependencies_parsed_at":"2023-06-08T00:45:22.665Z","dependency_job_id":null,"html_url":"https://github.com/elgohr/go-await","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elgohr%2Fgo-await","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elgohr%2Fgo-await/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elgohr%2Fgo-await/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elgohr%2Fgo-await/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elgohr","download_url":"https://codeload.github.com/elgohr/go-await/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415928,"owners_count":20935384,"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":["await","concurrency","go","golang","testing","testing-tools"],"created_at":"2024-10-09T18:46:59.702Z","updated_at":"2025-04-05T23:42:01.085Z","avatar_url":"https://github.com/elgohr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-await\nTesting concurrency in Golang \n\n`go get -u github.com/elgohr/go-await`\n\n## Chuck Norris doesn't sleep, he waits\nI saw so many test code, where people are waiting on async execution by sleeping (time.Sleep).  \nThis is\n* not efficient, as you may sleep longer for checking values then you would need\n* not consistent , as you may sleep longer than your timeout\n* dangerous, as some code didn't even have timeouts\n\nIn this way I'm trying to illustrate a way to do this easily, by using standard goroutines and channels.  \nYou may also use this as a library for not playing copy cat :-)\n\n## Example\n```\nimport (\"github.com/elgohr/go-await/wait\")\n\nawaiting := make(chan interface{}, 1)\n\nremoteServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\tawaiting \u003c- r.Method\n\tw.WriteHeader(http.StatusOK)\n}))\ndefer remoteServer.Close()\n\nthisCouldBeYourAsyncFunction := func() {\n\tgo func() {\n\t\tres, _ := http.Get(remoteServer.URL)\n\t\tdefer res.Body.Close()\n\t}()\n}\nthisCouldBeYourAsyncFunction()\n\nreturns := wait.For(awaiting, 1*time.Second)\nif returns != \"GET\" {\n\tt.Errorf(\"Expected GET, but got %v\", returns)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felgohr%2Fgo-await","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felgohr%2Fgo-await","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felgohr%2Fgo-await/lists"}