{"id":17912663,"url":"https://github.com/danielgatis/go-ctrlc","last_synced_at":"2025-04-03T07:13:57.956Z","repository":{"id":57648577,"uuid":"445009533","full_name":"danielgatis/go-ctrlc","owner":"danielgatis","description":"Gracefully quit when you press ctrl-c.","archived":false,"fork":false,"pushed_at":"2022-01-06T19:08:06.000Z","size":4,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-08T20:47:33.118Z","etag":null,"topics":["ctrl-c","go","golang"],"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/danielgatis.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":"2022-01-06T02:02:57.000Z","updated_at":"2022-04-23T07:58:59.000Z","dependencies_parsed_at":"2022-09-13T22:01:35.489Z","dependency_job_id":null,"html_url":"https://github.com/danielgatis/go-ctrlc","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/danielgatis%2Fgo-ctrlc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ctrlc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ctrlc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-ctrlc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielgatis","download_url":"https://codeload.github.com/danielgatis/go-ctrlc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246952278,"owners_count":20859812,"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":["ctrl-c","go","golang"],"created_at":"2024-10-28T19:46:28.342Z","updated_at":"2025-04-03T07:13:57.932Z","avatar_url":"https://github.com/danielgatis.png","language":"Go","readme":"# Go - Ctrlc\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/danielgatis/go-ctrlc?style=flat-square)](https://goreportcard.com/report/github.com/danielgatis/go-ctrlc)\n[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/danielgatis/go-ctrlc/master/LICENSE)\n[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/danielgatis/go-ctrlc)\n\nGracefully quit when you press ctrl-c.\n\n## Install\n\n```bash\ngo get -u github.com/danielgatis/go-ctrlc\n```\n\nAnd then import the package in your code:\n\n```go\nimport \"github.com/danielgatis/go-ctrlc\"\n```\n\n### Example\n\nAn example described below is one of the use cases.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/danielgatis/go-ctrlc\"\n)\n\nfunc main() {\n\ttick := time.NewTicker(time.Second)\n\texit := make(chan struct{})\n\n\tctrlc.Watch(func() {\n\t\texit \u003c- struct{}{}\n\t})\n\n\tfor {\n\t\tselect {\n\t\tcase \u003c-exit:\n\t\t\tfmt.Println(\"bye!\")\n\t\t\tos.Exit(0)\n\t\tcase \u003c-tick.C:\n\t\t\tfmt.Println(time.Now())\n\t\t}\n\t}\n}\n```\n\n```\n❯ go run main.go\n2022-01-06 12:08:46.015813 -0300 -03 m=+1.000276951\n2022-01-06 12:08:47.016224 -0300 -03 m=+2.000688652\n^Cbye!\n```\n\n### License\n\nCopyright (c) 2021-present [Daniel Gatis](https://github.com/danielgatis)\n\nLicensed under [MIT License](./LICENSE)\n\n### Buy me a coffee\n\nLiked some of my work? Buy me a coffee (or more likely a beer)\n\n\u003ca href=\"https://www.buymeacoffee.com/danielgatis\" target=\"_blank\"\u003e\u003cimg src=\"https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\"\u003e\u003c/a\u003e\n","funding_links":["https://www.buymeacoffee.com/danielgatis"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgatis%2Fgo-ctrlc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielgatis%2Fgo-ctrlc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgatis%2Fgo-ctrlc/lists"}