{"id":37173035,"url":"https://github.com/apperia-de/goroutine","last_synced_at":"2026-01-14T20:13:52.163Z","repository":{"id":57620154,"uuid":"390449030","full_name":"apperia-de/goroutine","owner":"apperia-de","description":"A goroutine wrapper for creating and running panic safe goroutines.","archived":false,"fork":false,"pushed_at":"2021-08-08T10:34:07.000Z","size":49,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T19:09:22.702Z","etag":null,"topics":["goroutine","panic","safe","wrapper"],"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/apperia-de.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":"2021-07-28T17:47:53.000Z","updated_at":"2024-01-10T15:03:28.000Z","dependencies_parsed_at":"2022-09-16T19:30:21.102Z","dependency_job_id":null,"html_url":"https://github.com/apperia-de/goroutine","commit_stats":null,"previous_names":["apperia-de/goroutine","sknr/goroutine"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/apperia-de/goroutine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apperia-de%2Fgoroutine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apperia-de%2Fgoroutine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apperia-de%2Fgoroutine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apperia-de%2Fgoroutine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apperia-de","download_url":"https://codeload.github.com/apperia-de/goroutine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apperia-de%2Fgoroutine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["goroutine","panic","safe","wrapper"],"created_at":"2026-01-14T20:13:51.457Z","updated_at":"2026-01-14T20:13:52.155Z","avatar_url":"https://github.com/apperia-de.png","language":"Go","readme":"\u003cimg width=\"150\" src=\"zorro.svg\" alt=\"logo\"\u003e\n\n# goroutine\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/sknr/goroutine)](https://goreportcard.com/report/github.com/sknr/goroutine)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/sknr/goroutine?style=flat)\n![GitHub](https://img.shields.io/github/license/sknr/goroutine)\n\nA goroutine wrapper for creating and running panic safe goroutines.\n\nThe purpose of this package is to provide a simple wrapper function for goroutines, which automatically handles panics\nin goroutines. Starting a new goroutine without taking care of recovering from a possible panic in that goroutine itself\ncould crash the whole application.\n\nThe `Go` function runs an arbitrary function `f` in a separate goroutine, which handles the recovering from panic within\nthat goroutine.\n\n## Installation\n\n`go get -u github.com/sknr/goroutine`\n\n## Usage (with dot import)\n\nInstead of running\n\n```\ngo func() {\n    panic(\"Panic raised in goroutine\")\n}()\n```\n\nsimply call\n\n```\nGo(func() {\n    panic(\"Panic raised in goroutine\")\n})\n```\n\nin order to create a panic safe goroutine.\n\nFunctions with multiple input params must be wrapped within an anonymous function.\n\nInstead of running\n\n```\ngo func(a, b int) {\n    panic(a+b)\n}(21,21)\n```\n\nsimply call\n\n```\nGo(func() {\n    func(a, b int) {\n        panic(a+b)\n    }(21,21)\n})\n```\n\n## Examples\n\n```\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/sknr/goroutine\"\n    \"log\"\n)\n\nfunc init() {\n    // Override the default recover function.\n    goroutine.SetDefaultRecoverFunc(func(v interface{}, done chan\u003c- error) {\n        log.Printf(\"%v\", v)\n        done \u003c- fmt.Errorf(\"panic in goroutine successfully recovered\")\n    })\n}\n\nfunc main() {\n    for i := -3; i \u003c= 3; i++ {\n        err := \u003c-goroutine.Go(func() {\n            func(a, b int) {\n                log.Println(a, \"/\", b, \"=\", a/b)\n            }(10, i)\n        })\n        if err != nil {\n            log.Println(err)\n        }\n    }\n}\n```\n\n### Set a new default recover function\n\nIn order to override the default recover function for new goroutines (created with `Go(func())` or `New(func())`),\nsimply set a custom recover function of type `RecoverFunc` with `SetDefaultRecoverFunc`\n\n### Create a new Goroutine instance with a custom recover function\n\nIf you need different recover functions for different goroutines, you can simply call\n\n```\ngoroutine.New(func() {\n    func(name string) {\n        panic(fmt.Sprintln(\"Hallo\", name))\n    }(\"Welt\")\n}).WithRecoverFunc(func(v interface{}, done chan\u003c- error) {\n    log.Printf(\"Custom recover function in goroutine, with error: %v\", v)\n}).Go()\n```\n\n## Logo\n- Gopher by [Gophers](https://github.com/egonelbre/gophers)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapperia-de%2Fgoroutine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapperia-de%2Fgoroutine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapperia-de%2Fgoroutine/lists"}