{"id":24200091,"url":"https://github.com/lesiw/defers","last_synced_at":"2025-09-21T23:32:28.215Z","repository":{"id":244701226,"uuid":"816004221","full_name":"lesiw/defers","owner":"lesiw","description":"Global defers for Go.","archived":false,"fork":false,"pushed_at":"2024-12-23T23:15:42.000Z","size":27,"stargazers_count":17,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-23T23:27:41.968Z","etag":null,"topics":["go","go-package","golang"],"latest_commit_sha":null,"homepage":"https://lesiw.io/defers","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/lesiw.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":"2024-06-16T19:41:22.000Z","updated_at":"2024-12-23T23:15:45.000Z","dependencies_parsed_at":"2024-10-25T03:38:38.680Z","dependency_job_id":"9dc6c4c1-abe9-4558-88c3-4040921c5632","html_url":"https://github.com/lesiw/defers","commit_stats":null,"previous_names":["lesiw/defers"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesiw%2Fdefers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesiw%2Fdefers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesiw%2Fdefers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesiw%2Fdefers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lesiw","download_url":"https://codeload.github.com/lesiw/defers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233808153,"owners_count":18733525,"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":["go","go-package","golang"],"created_at":"2025-01-13T20:41:01.373Z","updated_at":"2025-09-21T23:32:22.920Z","avatar_url":"https://github.com/lesiw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lesiw.io/defers\n\n[![Go Reference](https://pkg.go.dev/badge/lesiw.io/defers.svg)](https://pkg.go.dev/lesiw.io/defers)\n\nPackage defers handles program-wide defers.\n\nDefers are executed when defers.Exit() is called or when an interrupt signal is\ncaught, whichever happens first.\n\nIf an interrupt signal is caught, the program will exit with a status of 128\nplus the signal number. In the event the signal number cannot be determined, the\nprogram will exit with exit status 1.\n\n## Example\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"os\"\n\n    \"lesiw.io/defers\"\n)\n\n// Set stop to true to halt the program.\n// This forces the Go Playground to send an os.Interrupt.\n// Global defers will still run before the program ends.\nvar stop = false\n\nvar success bool\n\nfunc main() {\n    defer defers.Run()\n    defers.Add(func() {\n        if success {\n            fmt.Fprintln(os.Stderr, \"The program executed successfully.\")\n        } else {\n            fmt.Fprintln(os.Stderr, \"The program was interrupted.\")\n        }\n    })\n    fmt.Println(\"Preparing to send a greeting...\")\n    if stop {\n        select {}\n    }\n    fmt.Println(\"Hello world!\")\n    success = true\n}\n```\n\n[▶️ Run this example on the Go Playground](https://go.dev/play/p/Ser5Yr68rko)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesiw%2Fdefers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flesiw%2Fdefers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesiw%2Fdefers/lists"}