{"id":15393860,"url":"https://github.com/mitchellh/multistep","last_synced_at":"2025-08-20T14:32:39.740Z","repository":{"id":8791909,"uuid":"10483549","full_name":"mitchellh/multistep","owner":"mitchellh","description":"multistep is a Go library for building up complex actions using discrete steps.","archived":false,"fork":false,"pushed_at":"2017-09-01T11:47:18.000Z","size":23,"stargazers_count":149,"open_issues_count":4,"forks_count":19,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-12-16T18:39:35.194Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitchellh.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":"2013-06-04T16:42:54.000Z","updated_at":"2024-11-28T16:27:18.000Z","dependencies_parsed_at":"2022-09-26T20:21:22.712Z","dependency_job_id":null,"html_url":"https://github.com/mitchellh/multistep","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/mitchellh%2Fmultistep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fmultistep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fmultistep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fmultistep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitchellh","download_url":"https://codeload.github.com/mitchellh/multistep/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230431104,"owners_count":18224655,"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-10-01T15:20:35.759Z","updated_at":"2024-12-19T12:11:37.821Z","avatar_url":"https://github.com/mitchellh.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# multistep\n\nmultistep is a Go library for building up complex actions using discrete,\nindividual \"steps.\" These steps are strung together and run in sequence\nto achieve a more complex goal. The runner handles cleanup, cancelling, etc.\nif necessary.\n\n## Basic Example\n\nMake a step to perform some action. The step can access your \"state\",\nwhich is passed between steps by the runner.\n\n```go\ntype stepAdd struct{}\n\nfunc (s *stepAdd) Run(state multistep.StateBag) multistep.StepAction {\n    // Read our value and assert that it is they type we want\n    value := state.Get(\"value\").(int)\n    fmt.Printf(\"Value is %d\\n\", value)\n\n\t// Store some state back\n\tstate.Put(\"value\", value + 1)\n    return multistep.ActionContinue\n}\n\nfunc (s *stepAdd) Cleanup(multistep.StateBag) {\n\t// This is called after all the steps have run or if the runner is\n\t// cancelled so that cleanup can be performed.\n}\n```\n\nMake a runner and call your array of Steps.\n\n```go\nfunc main() {\n    // Our \"bag of state\" that we read the value from\n    state := new(multistep.BasicStateBag)\n\tstate.Put(\"value\", 0)\n\n    steps := []multistep.Step{\n        \u0026stepAdd{},\n        \u0026stepAdd{},\n        \u0026stepAdd{},\n    }\n\n    runner := \u0026multistep.BasicRunner{Steps: steps}\n\n    // Executes the steps\n    runner.Run(state)\n}\n```\n\nThis will produce:\n\n```\nValue is 0\nValue is 1\nValue is 2\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Fmultistep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitchellh%2Fmultistep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Fmultistep/lists"}