{"id":13571299,"url":"https://github.com/alexellis/go-execute","last_synced_at":"2025-04-06T03:07:04.037Z","repository":{"id":36766041,"uuid":"214016092","full_name":"alexellis/go-execute","owner":"alexellis","description":"Automate CLI commands with Go","archived":false,"fork":false,"pushed_at":"2024-01-13T04:30:02.000Z","size":30,"stargazers_count":165,"open_issues_count":2,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T02:05:21.941Z","etag":null,"topics":["exec","go","golang","library","stdlib"],"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/alexellis.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":"2019-10-09T20:21:48.000Z","updated_at":"2025-03-23T10:52:42.000Z","dependencies_parsed_at":"2022-08-08T17:01:09.762Z","dependency_job_id":"8ac9d4d9-0083-4644-908b-8e4b2ada2308","html_url":"https://github.com/alexellis/go-execute","commit_stats":{"total_commits":27,"total_committers":3,"mean_commits":9.0,"dds":0.07407407407407407,"last_synced_commit":"5f0a7b666c99d9170c41d0c704a3cd9e7dbff971"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexellis%2Fgo-execute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexellis%2Fgo-execute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexellis%2Fgo-execute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexellis%2Fgo-execute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexellis","download_url":"https://codeload.github.com/alexellis/go-execute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"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":["exec","go","golang","library","stdlib"],"created_at":"2024-08-01T14:01:00.746Z","updated_at":"2025-04-06T03:07:04.014Z","avatar_url":"https://github.com/alexellis.png","language":"Go","readme":"## go-execute\n\nA wrapper for Go's command execution packages.\n\n`go get github.com/alexellis/go-execute/v2`\n\n## Docs\n\nSee docs at pkg.go.dev: [github.com/alexellis/go-execute](https://pkg.go.dev/github.com/alexellis/go-execute)\n\n## go-execute users\n\n[Used by dozens of projects as identified by GitHub](https://github.com/alexellis/go-execute/network/dependents), notably:\n\n* [alexellis/arkade](https://github.com/alexellis/arkade)\n* [openfaas/faas-cli](https://github.com/openfaas/faas-cli)\n* [inlets/inletsctl](https://github.com/inlets/inletsctl)\n* [inlets/cloud-provision](https://github.com/inlets/cloud-provision)\n* [alexellis/k3sup](https://github.com/alexellis/k3sup)\n* [openfaas/connector-sdk](https://github.com/openfaas/connector-sdk)\n* [openfaas-incubator/ofc-bootstrap](https://github.com/openfaas-incubator/ofc-bootstrap)\n\nCommunity examples:\n\n* [dokku/lambda-builder](https://github.com/dokku/lambda-builder)\n* [027xiguapi/pear-rec](https://github.com/027xiguapi/pear-rec)\n* [cnrancher/autok3s](https://github.com/cnrancher/autok3s)\n* [ainsleydev/hupi](https://github.com/ainsleydev/hupi)\n* [andiwork/andictl](https://github.com/andiwork/andictl)\n* [tonit/rekind](https://github.com/tonit/rekind)\n* [lucasrod16/ec2-k3s](https://github.com/lucasrod16/ec2-k3s)\n* [seaweedfs/seaweed-up](https://github.com/seaweedfs/seaweed-up)\n* [jsiebens/inlets-on-fly](https://github.com/jsiebens/inlets-on-fly)\n* [jsiebens/hashi-up](https://github.com/jsiebens/hashi-up)\n* [edgego/ecm](https://github.com/edgego/ecm)\n* [ministryofjustice/cloud-platform-terraform-upgrade](https://github.com/ministryofjustice/cloud-platform-terraform-upgrade)\n* [mattcanty/go-ffmpeg-transcode](https://github.com/mattcanty/go-ffmpeg-transcode)\n* [Popoola-Opeyemi/meeseeks](https://github.com/Popoola-Opeyemi/meeseeks)\n* [aidun/minicloud](https://github.com/aidun/minicloud)\n\nFeel free to add a link to your own projects in a PR.\n\n## Main options\n\n* `DisableStdioBuffer` - Discard Stdio, rather than buffering into memory\n* `StreamStdio` - Stream stderr and stdout to the console, useful for debugging and testing\n* `Shell` - Use bash as a shell to execute the command, rather than exec a binary directly\n* `StdOutWriter` - an additional writer for stdout, useful for mutating or filtering the output\n* `StdErrWriter` - an additional writer for stderr, useful for mutating or filtering the output\n* `PrintCommand` - print the command to stdout before executing it\n\n## Example of exec without streaming to STDIO\n\nThis example captures the values from stdout and stderr without relaying to the console. This means the values can be inspected and used for automation.\n\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\n\texecute \"github.com/alexellis/go-execute/v2\"\n\t\"context\"\n)\n\nfunc main() {\n\tcmd := execute.ExecTask{\n\t\tCommand:     \"docker\",\n\t\tArgs:        []string{\"version\"},\n\t\tStreamStdio: false,\n\t}\n\n\tres, err := cmd.Execute(context.Background())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif res.ExitCode != 0 {\n\t\tpanic(\"Non-zero exit code: \" + res.Stderr)\n\t}\n\n\tfmt.Printf(\"stdout: %s, stderr: %s, exit-code: %d\\n\", res.Stdout, res.Stderr, res.ExitCode)\n}\n```\n\n## Example with \"shell\" and exit-code 0\n\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\n\texecute \"github.com/alexellis/go-execute/v2\"\n\t\"context\"\n)\n\nfunc main() {\n\tls := execute.ExecTask{\n\t\tCommand: \"ls\",\n\t\tArgs:    []string{\"-l\"},\n\t\tShell:   true,\n\t}\n\tres, err := ls.Execute(context.Background())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"stdout: %q, stderr: %q, exit-code: %d\\n\", res.Stdout, res.Stderr, res.ExitCode)\n}\n```\n\n## Example with \"shell\" and exit-code 1\n\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"context\"\n\texecute \"github.com/alexellis/go-execute/v2\"\n)\n\nfunc main() {\n\tls := execute.ExecTask{\n\t\tCommand: \"exit 1\",\n\t\tShell:   true,\n\t}\n\tres, err := ls.Execute(context.Background())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"stdout: %q, stderr: %q, exit-code: %d\\n\", res.Stdout, res.Stderr, res.ExitCode)\n}\n```\n\n## Contributing\n\nCommits must be signed off with `git commit -s`\n\nLicense: MIT\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexellis%2Fgo-execute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexellis%2Fgo-execute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexellis%2Fgo-execute/lists"}