{"id":34565905,"url":"https://github.com/henrikfricke/go-lifecycle","last_synced_at":"2026-05-28T11:32:11.308Z","repository":{"id":57638025,"uuid":"97029543","full_name":"HenrikFricke/go-lifecycle","owner":"HenrikFricke","description":"life cycle manager for Go","archived":false,"fork":false,"pushed_at":"2017-07-13T19:54:53.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-01-27T12:55:36.119Z","etag":null,"topics":["cycle","go","golang","library","life","lifecycle","task-runner"],"latest_commit_sha":null,"homepage":"http://gopkg.in/henrikfricke/go-lifecycle.v1","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/HenrikFricke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-12T16:27:54.000Z","updated_at":"2017-07-17T10:34:22.000Z","dependencies_parsed_at":"2022-09-26T20:21:07.829Z","dependency_job_id":null,"html_url":"https://github.com/HenrikFricke/go-lifecycle","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/HenrikFricke/go-lifecycle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenrikFricke%2Fgo-lifecycle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenrikFricke%2Fgo-lifecycle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenrikFricke%2Fgo-lifecycle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenrikFricke%2Fgo-lifecycle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HenrikFricke","download_url":"https://codeload.github.com/HenrikFricke/go-lifecycle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenrikFricke%2Fgo-lifecycle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27999345,"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","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cycle","go","golang","library","life","lifecycle","task-runner"],"created_at":"2025-12-24T09:04:20.422Z","updated_at":"2025-12-24T09:05:11.304Z","avatar_url":"https://github.com/HenrikFricke.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-lifecycle\n\n## Usage\n\nThis project uses [gopkg](http://labix.org/gopkg.in) to handle versioning. Find more information about how to install and where to find the API documentation [here](http://gopkg.in/henrikfricke/go-lifecycle.v1).\n\n## About the project\n\nThis project is inspired by the [Lifecycle](https://serverless.com/blog/writing-serverless-plugins/#lifecycle-events) of the [Serverless Framework](https://serverless.com/). The Serverless CLI handles plugins, which are able to hook before or after a process. Every plugin is also a process in the lifecycle, so other plugins can hook before or after a plugin as well. I really liked the way how Serverless build the plugin architecture and I wanted to think about how to achieve this process management in Go.\n\n## Concept\n\nThe idea is to creeate a sequence of tasks and execute them afterwards. So we have something like a queue with tasks. The tasks will be executed with the [FIFO](https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)) method. But you can also have the special behaviour of hooks: You can add a pre or post hook to every task and also to every hook (because technically every hook is also a task).\n\n## Example\n\nLet's take a look to a simple example:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\tglc \"github.com/HenrikFricke/go-lifecycle\"\n)\n\nconst (\n\ttask1Name glc.TaskName = \"task_one\"\n\ttask2Name              = \"task_two\"\n\tpreHook                = \"pre_hook\"\n)\n\nfunc printOut(luggage interface{}) {\n\tfmt.Println(\"I'am a task\")\n}\n\nfunc printOutHook(luggage interface{}) {\n\tfmt.Println(\"I'am a hook\")\n}\n\nfunc main() {\n\tlifecycle := glc.NewLifecycle()\n\n\tlifecycle.AddTask(task1Name, printOut)\n\tlifecycle.AddTask(task2Name, printOut)\n\n\tlifecycle.AddPreHook(task2Name, preHook, printOutHook)\n\n\tlifecycle.Execute(nil)\n}\n```\n\nWe define here two tasks and one pre hook for the second task, the output of this example is:\n\n```bash\nI'am a task\nI'am a hook\nI'am a task\n```\n\nYou can find a more complex example in the `example` folder. You can clone this repository on your local machine and execute the example with `go run example/example.go`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrikfricke%2Fgo-lifecycle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenrikfricke%2Fgo-lifecycle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrikfricke%2Fgo-lifecycle/lists"}