{"id":20365859,"url":"https://github.com/cycoresystems/gocond","last_synced_at":"2026-05-11T14:31:35.955Z","repository":{"id":57600601,"uuid":"79771451","full_name":"CyCoreSystems/gocond","owner":"CyCoreSystems","description":"Conditional goroutines","archived":false,"fork":false,"pushed_at":"2017-01-23T05:08:34.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-25T15:03:42.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/CyCoreSystems.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":"2017-01-23T04:58:05.000Z","updated_at":"2017-01-23T04:58:59.000Z","dependencies_parsed_at":"2022-08-24T13:37:15.349Z","dependency_job_id":null,"html_url":"https://github.com/CyCoreSystems/gocond","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/CyCoreSystems%2Fgocond","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fgocond/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fgocond/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fgocond/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyCoreSystems","download_url":"https://codeload.github.com/CyCoreSystems/gocond/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241907612,"owners_count":20040500,"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":[],"created_at":"2024-11-15T00:20:37.208Z","updated_at":"2026-05-11T14:31:35.891Z","avatar_url":"https://github.com/CyCoreSystems.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gocond [![](https://godoc.org/github.com/CyCoreSystems/gocond?status.svg)](http://godoc.org/github.com/CyCoreSystems/gocond)\n\nSimple syntactic sugar for transacting conditional goroutines\n\nThe idea of a conditional goroutine is that a function needs to be called and that function needs to run in the background.  Normally in such a case, you would execute the function inside a goroutine:\n\n```go\n   go myFunc()\n```\n\nHowever, there exist a couple common problems here:\n   - There may be checks which must be performed which may preclude the goroutine from running\n   - There may be synchronous actions which must be performed before the surrounding code is allowed to continue execution\n\nTo be sure, there are plenty of solutions to each of these problems.\n\nYou could embed the goroutine inside the subroutine:\n\n```go\n   func Subroutine(a int) error {\n     if a \u003c 1 {\n       return errors.New(\"A must not be less than 1\")\n     }\n     go func() {\n       // do stuff\n     }()\n     return nil\n   }\n\n   func main() {\n     err := Subroutine(1)\n     // do stuff\n   }\n```\n\nThe problem here is that when reading through the top-level logic, it is\nunclear that Subroutine runs in the background.\n\nYou could provide a channel for signaling:\n\n```go\n   func Subroutine(a int, errCh \u003c-chan error) {\n     defer close(errCh)\n \n     if a \u003c 1 {\n       errCh \u003c-errors.New(\"A must not be less than 1\")\n     }\n \n     go func() {\n       // do stuff\n     }()\n     return\n   }\n```\n\nThis latter path provides a fairly flexible system, with the cost of an\nadditional temporary goroutine.  What this package does, essentially, is\nprovide simple wrapper to do exactly this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycoresystems%2Fgocond","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcycoresystems%2Fgocond","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycoresystems%2Fgocond/lists"}